Skip to content

Instantly share code, notes, and snippets.

@lutsen
Created April 13, 2014 11:52
Show Gist options
  • Save lutsen/10580836 to your computer and use it in GitHub Desktop.
Save lutsen/10580836 to your computer and use it in GitHub Desktop.
Swap a "main" image by hovering over a thumb image.
// Swap a "main" image by hovering over a thumb image.
// They both need to have the same scr, except for the "template" part.
$(function () {
$( '.thumbimg' ).each( function (i) {
$( this ).on({
mouseenter: function() {
$('#mainimg').attr(
'src',
$( this ).attr('src').replace('fit164x164', 'fit555x555') // Replace the template part in the src
);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment