Last active
June 8, 2016 17:29
-
-
Save farnscosnippet/5529877 to your computer and use it in GitHub Desktop.
JS: Rollover Images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Rollover Images --> | |
<script type="text/javascript"> | |
$(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() { | |
$('<img />').attr('src', $(this).attr('data-hover')); | |
});; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment