Short answer: you want to set the handler to a function:
elemm.onclick = function() { alert('blah'); };
Slightly longer answer: you'll have to write a few more lines of code to get that to work consistently across browsers.
The fact is that even the sligthly-longer-code that might solve that particular problem across a set of common browsers will still come with problems of its own. So if you don't care about cross-browser support, go with the totally short one. If you care about it and absolutely only want to get this one single thing working, go with a combination of addEventListener
and attachEvent
. If you want to be able to extensively create objects and add and remove event listeners throughout your code, and want that to work across browsers, you definitely want to delegate that responsibility to a library such as jQuery.