Saturday, June 11, 2011

jQuery Image RollOver

Here is the JQuery Script

$(function() {
$('img[data-hover]').hover(function() {
$(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp');
}).each(function() {
$('').attr('src', $(this).attr('data-hover'));
});;
});

Here is the var you add to the img

<br /><img data-hover="second.gif" src="first.gif" /><br />

Here is the original link
http://www.selfcontained.us/2008/03/08/simple-jquery-image-rollover-script/

No comments:

Post a Comment