Posted By

mikemetcalf on 09/18/09


Tagged

jquery replacement rollover


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

sulfurito
retrobou
e11world


Simple jQuery image hover replacement


 / Published in: jQuery
 

URL: http://www.selfcontained.us/2008/03/08/simple-jquery-image-rollover-script/

Add a "rollover" class and hover="img/src-hover.jpg" to the image in question.

  1. $(function() {
  2. $('.rollover').hover(function() {
  3. var currentImg = $(this).attr('src');
  4. $(this).attr('src', $(this).attr('hover'));
  5. $(this).attr('hover', currentImg);
  6. }, function() {
  7. var currentImg = $(this).attr('src');
  8. $(this).attr('src', $(this).attr('hover'));
  9. $(this).attr('hover', currentImg);
  10. });
  11. });

Report this snippet  

You need to login to post a comment.