JQuery make a copy of HTML and save it for later search

I need to be able to recover HTML code inside a div, as it was on the page. I need this because I want to make some changes to the HTML code after the page is ready, and then return it the way it was on the page when I need it.

I was thinking of using a clone, but how do I just copy the contents of a div without pasting it? I need to copy the contents of the div on the page, done, and then paste it / replace the div with the original when I need to.

I'm new to jquery, I tried a few things with no luck, I can't find out what I need. Thanks for any suggestion!

+6
source share
1 answer

You can copy it to a variable later.

var originalContent; $(document).ready(function() { originalContent = $('#theDiv').clone(); }); 
+7
source

Source: https://habr.com/ru/post/949343/


All Articles