Skip to content

Instantly share code, notes, and snippets.

@neatville
Created September 20, 2014 03:46
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 neatville/7191a726a3ba2494f4e8 to your computer and use it in GitHub Desktop.
Save neatville/7191a726a3ba2494f4e8 to your computer and use it in GitHub Desktop.
Use jQuery replaceWith for easy yet powerful DOM manipulation.
var href = $(".link").attr("href");
var textOf = $(".link").text();
$( "a" ).click(function() {
$( this ).replaceWith( "<textarea autofocus>" + href + " -> " + textOf + "</textarea>" );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment