Dynamically Changing an img tag's onemouseover attribute with Javascript nulls it instead
- by ?s?zs?
I want to create an img that has four different states:
State 1 over
State 1 out
State 2 over
State 2 out
Each state is a different image, and the user can toggle between states 1 and 2 by clicking on the image.
To do this I change the src when the image is clicked and the onmouseover and onmouseout attributes of the img element. However when the…