Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery clone original HTML not DOM

Tags:

jquery

dom

clone

I need to clone a section of markup that has already been modified in the DOM. I want to get the original HTML source - what is seen in View > Source.

clone() uses what's in the DOM

like image 266
Anthony Avatar asked Mar 03 '26 05:03

Anthony


2 Answers

You can't.

If you need it, store the original markup in a JavaScript var before making any modifications.

like image 78
ThiefMaster Avatar answered Mar 05 '26 21:03

ThiefMaster


Try putting it in a variable before the DOM is manipulated. I use this method for jQuery templating... var template = $('#template').html()

like image 28
pixelbobby Avatar answered Mar 05 '26 21:03

pixelbobby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!