Ok so I’m going to try and make this as clear as possible. I want to write a function that when called will add an onmouseout attribute to an image.
Before the image is moused over.
<img src="myfile.jpg" onmouseover="function()" />
After
<img src="myfile.jpg" onmouseover="function()" onmouseout="anotherFunction()" />
I would also like to change the picture with function() and then onmouseout set the picture back to the original. I know how to change the pictures with onmouseover and onmouseout right in the image code but I’m trying to simplify this as I have to do the image changy thing about 100 times and I dont want to write out the code that many times. Gah I hope that was clear.
Here we go http://jsfiddle.net/5U9w9/2/
I’m going to update the jsFidle with more comments and will update the link here too.
javascript
Update
AddEventin the place ofaddEventListner()for IE support. (CREDIT: @James Hill’s answer)