Skip to content

Instantly share code, notes, and snippets.

@farnscosnippet
Last active June 8, 2016 17:29
Show Gist options
  • Save farnscosnippet/5529877 to your computer and use it in GitHub Desktop.
Save farnscosnippet/5529877 to your computer and use it in GitHub Desktop.
JS: Rollover Images
<!-- 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