Skip to content

Instantly share code, notes, and snippets.

@tomfordweb
Created April 24, 2018 12:03
Show Gist options
  • Save tomfordweb/43f540906ff0f73ddbeb4d80314b1a3d to your computer and use it in GitHub Desktop.
Save tomfordweb/43f540906ff0f73ddbeb4d80314b1a3d to your computer and use it in GitHub Desktop.
jQuery image hover boilerplate
// handles hover for images
$('.home .callout').hover(function() {
// hover in
$(this).find('img').attr('src', function(index, attr) {
// foo1.png -> foo2.png
return attr.replace('1.png','2.png');
});
}, function() {
// hover out
$(this).find('img').attr('src', function(index, attr) {
// foo2.png -> foo1.png
return attr.replace('2.png','1.png');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment