Example

Clone all p elements and insert them at the end of the body element:

$("button").click(function(){
  $("p").clone().appendTo("body");
});

Try it yourself »

Definition and Usage

The clone() method makes a copy of selected elements, including child nodes, text and attributes.


Syntax

$(selector).clone(includeEvents)

Parameter Description
includeEvents Optional. A boolean value that specifies whether or not the event handlers should be copied.

By default, event handlers are not included in the copy.


Examples

Try it Yourself - Examples

Copy an element including event handlers
How to use the clone() method to copy an element, including event handlers.