Skip to content

Instantly share code, notes, and snippets.

@mikedugan
Created November 12, 2013 17:49
Show Gist options
  • Save mikedugan/7435411 to your computer and use it in GitHub Desktop.
Save mikedugan/7435411 to your computer and use it in GitHub Desktop.
wraps an img in anchor from sibling, and removes the anchor
//where containerDiv is the parent of the img and a
//where imgwrap is the anchor the img will be wrapped in
$('.containerDiv').each(function() {
$('img',$(this)).wrap('<a href="' + $('.imgwrap',$(this)).attr('href') + '"></a>');
});
$('.imgwrap').remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment