Latest web development tutorials

jQuery clone () method

jQuery HTML / CSS Methods jQuery HTML / CSS Methods

Examples

All clone <p> element, and inserted into the <body> element at the end:

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

try it"

Definition and Usage

clone () method to generate a copy of the selected elements, including child nodes, and text attributes.


grammar

$(selector).clone(true|false)

参数 描述
true 规定需复制事件处理程序。
false 默认。规定不复制事件处理程序。


Examples

More examples

Copy the element that contains the event handler
How to use the clone () method to copy an element that contains the event handler.


jQuery HTML / CSS Methods jQuery HTML / CSS Methods