jQuery clone duplicate IDs

后端 未结 9 1890
醉梦人生
醉梦人生 2020-12-04 19:03

I have an HTML element with a large collection of unordered lists contained within it. I need to clone this element to place elsewhere on the page with different styles adde

9条回答
  •  盖世英雄少女心
    2020-12-04 19:32

    I believe this is the best way

    var $clone = $("#MainConfig").clone(false);
    $clone.removeAttr('id'); // remove id="MainConfig"
    $clone.find('[id]').removeAttr('id'); // remove all other id attributes
    $clone.appendTo($("#smallConfig")); // add to DOM.
    

提交回复
热议问题