Created
April 24, 2018 12:03
-
-
Save tomfordweb/43f540906ff0f73ddbeb4d80314b1a3d to your computer and use it in GitHub Desktop.
jQuery image hover boilerplate
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
// 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