Last active
March 16, 2016 16:51
-
-
Save IAMIronmanSam/1e72ac7d90290189def3 to your computer and use it in GitHub Desktop.
Clone Div
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Do this on $(document).ready(function() { ... }) | |
| var divClone = $("#some_div").clone(); | |
| // Change the content temporarily | |
| $("#some_div").html("Yeah all good mate!"); | |
| // Use this command if you want to keep divClone as a copy of "#some_div" | |
| // Restore element with a copy of divClone | |
| $("#some_div").replaceWith(divClone.clone()); | |
| // Any changes to "#some_div" after this point will affect the value of divClone | |
| // Restore element with divClone itself | |
| $("#some_div").replaceWith(divClone); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment