From jQuery JavaScript Library
« Back to Manipulation
clone( )
Clone matched DOM Elements and select the clones.
This is useful for moving copies of the elements to another location in the DOM.
Examples:| Name | Type |
Clones all b elements (and selects the clones) and prepends them to all paragraphs.
$("b").clone().prependTo("p");
clone( true )
Clone matched DOM Elements, and all their event handlers, and select the clones.
This is useful for moving copies of the elements, and their events, to another location in the DOM.
Arguments:| true | Boolean | |
|---|
| Set to true to enable cloning of event handlers. |
Examples:| Name | Type |
Create a button that's able to clone itself - and have the clones themselves be clonable.
$("button").click(function(){
$(this).clone(true).insertAfter(this);
});