I am inserting elements into dom dynamically and for that i m using following steps :(jquery) The initial dom structure is as below:
<div parent div>
</div>
<div child div template>
</div>
- clone the parent div using jquery .clone()
- clone the child div and do manipulation
- append to the cloned parent
- do this for all child data
(parentdiv original).replaceAll(clonedparent)
Basically i want to clone the parent div in a manner so that it is available as a documentfragment and so that appending doesnt happen on the dom and gain performance .
Will jQuery clone()
give the performance advantage by behaving like documentfragment?
Or is there a better way to do this? I don't want to construct each child element as HTML string as the structure of them is pretty complex.