I have a few images and their rollover images. Using jQuery, I want to show/hide the rollover image when the onmousemove/onmouseout event happen. All my image names follow the same pattern, like this:
Original Image:
Image.gif
Rollover Image:
Imageover.gif
I want to insert and remove the "over" portion of image source in the onmouseover and onmouseout event, respectively.
How can I do it using jQuery?
I know you're asking about using jQuery, but you can achieve the same effect in browsers that have JavaScript turned off using CSS:
There's a longer description here
Even better, however, is to use sprites: simple-css-image-rollover
If you have more than one image and you need something generic that doesn't depend on a naming convention.
HTML
JavaScript
I was hoping for an über one liner like:
You may want to change the class of images from first line. If you need more image classes (or different path) you may use
and so on.
It should work, I didn't test it :)