Skip to content

Instantly share code, notes, and snippets.

@jerewall
Forked from tfevens/gist:4505057bec1f4a1d0b02
Last active August 29, 2015 14:15
Show Gist options
  • Save jerewall/22d4d50002c94481ed52 to your computer and use it in GitHub Desktop.
Save jerewall/22d4d50002c94481ed52 to your computer and use it in GitHub Desktop.
$('img.swap').click(function() {
var src = ($(this).attr('src'));
var swap = ($(this).data('swap'));
$(this).attr('src', swap );
$(this).data('swap', src );
});
// <img src="images/pic1.jpg" data-swap="images/pic2.jpg" class="swap">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment