最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - duplicate html element with jquery - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited Jun 10, 2019 at 15:11 Quamis asked Jan 24, 2010 at 14:48 QuamisQuamis 11.1k13 gold badges53 silver badges67 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

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)

  1. 暂无评论