I need some javascript code that dynamically adds an img tag to a div, and the img tag needs onmouseover and onmouseout handlers.
I have it working on Firefox. But
Ob's answer shows the correct method for attaching event listeners without using a JavaScript library (and was first), but I would like to add the following:
onmouseover/out should never be attached as attributes. Basically, you're gone through all the trouble of not doing
just to do it in your JavaScript. Event handlering callbacks should always be attached as event listeners via attachEvent for IE, and addEventListener for pretty much everyone else.