Posted By

omerta83 on 07/08/10


Tagged

javascript jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


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


 / Published in: JavaScript
 

  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  

You need to login to post a comment.