开发者

duplicate html element with jquery

开发者 https://www.devze.com 2022-12-17 04:28 出处:网络
anyone knows of any jquery开发者_如何学运维 plugin that handles duplication of some random html elements? I\'m looking for a way to dynamically add identical rows to a form.

anyone knows of any jquery开发者_如何学运维 plugin that handles duplication of some random html elements? I'm looking for a way to dynamically add identical rows to a form. I know its not hard to make, but i don't really want to reinvent the wheel here.


From jQuery API
The .clone() method, when used in conjunction with one of the insertion methods, is a convenient way to duplicate elements on a page.

$('originalSelector').clone().appendTo('selectorToPlaceClone')


For a native javascript solution, you can use .cloneNode(true)

duplicate = document.getElementById("originalSelector").cloneNode(true);


Use the native clone method ..

$('row_selector_here').clone().appendTo('your_form_selector_here');
0

精彩评论

暂无评论...
验证码 换一张
取 消