Sometimes we need to create dynamic dom element they might take reference of existing dom element.  Let's take some scenario we want to create widget which have same looks and functionality and we want to make it available all the pages of our website. in such a scenario we can't write code for each of the html page for the samething which we already created in previous page(widget). In order to solve this issue we use jquery clone function, below is the example of the clone object, in order to make it available we will store it in localstorage which is html5 features to store the data and object.

lets take a look of html file

<div class="realobject">
<div class="child_object0"></div>
<div class="child_object1"></div>

lets clone the realobject 

<script type="text/javascript">
var clone_object=$('.realobject').clone()


In above script code we define clone_oject and save into localstorage now you can access same div just calling function and append it to another html file
var clone_object_referee=localstorage.getItem('clone')

Happy coding....

Recent Articles
New service launch