Skip to content

Instantly share code, notes, and snippets.

@bretdavidson
Created April 30, 2014 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bretdavidson/4d58194f58b25abb84ae to your computer and use it in GitHub Desktop.
Save bretdavidson/4d58194f58b25abb84ae to your computer and use it in GitHub Desktop.
// Taken from: http://stackoverflow.com/a/9349999
// <img data-other-src="big-zebra.jpg" src="small-zebra.jpg">
// <img data-other-src="big-elephant.jpg" src="small-elephant.jpg">
// <img data-other-src="big-bear.jpg" src="small-bear.jpg">
$(function () {
$('img').on('mouseenter mouseleave', function () {
$(this).attr({
src: $(this).attr('data-other-src'),
'data-other-src': $(this).attr('src')
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment