jQuery clone – create a deep copy of matched elements

disable jQuery animations

The jQuery clone() Method creates a deep run time copy of set of matched DOM Elements  to another location in the DOM elements and select the clones.

This is very useful for run time copies of the elements to another location in the DOM elements.

Syntax:

$(selector).clone(true|false)

true: specifies the event handlers which should be copied
false: default. specifies the event handlers should not be copied

Read jQuery reference for more details.

Example of jQuery clone():

<p>This is a first paragraph.</p>
<p>This is a second paragraph.</p>
<script>
$(document).ready(function(){
$("p").clone().appendTo("body");
});
</script>

In the above example, it clone all <p> elements and then insert them at the end of the <body> element.

Must Read: Add table row dynamically in jQuery

For any types of queries, you can contact us on info@namasteui.com.

You may like:  imgAreaSelect - image crop jQuery plugin

Leave a Reply

Your email address will not be published. Required fields are marked *