narenarya

For restoring previous state of Html Element using Jquery

Nov 5th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. var divClone = $("#some_div").clone(); // Do this on $(document).ready(function() { ... })
  2.  
  3. $("#some_div").html("Yeah all good mate!"); // Change the content temporarily
  4.  
  5. // Use this command if you want to keep divClone as a copy of "#some_div"
  6. $("#some_div").replaceWith(divClone.clone()); // Restore element with a copy of divClone
  7.  
  8. // Any changes to "#some_div" after this point will affect the value of divClone
  9. $("#some_div").replaceWith(divClone);
Advertisement
Add Comment
Please, Sign In to add comment