How to retain information stripped from the DOM by .remove()


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //In the below example
  2. $("p").click(function(){
  3. $(this).toggleClass("off");
  4. });
  5. var p;
  6. $("button").click(function(){
  7. if ( p ) {
  8. p.appendTo("body");
  9. p = null;
  10. } else {
  11. p = $("p").detach();
  12. }
  13. });
  14.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.