Change inner elements id during clone

后端 未结 4 1278
天命终不由人
天命终不由人 2021-02-13 18:17

I\'m doing a clone of a DIV element on button click, I\'m able to change the value of ID of the DIV element I\'m cloning. But is it possible to change the id of the inner elemen

4条回答
  •  攒了一身酷
    2021-02-13 18:43

    You need to change all children's ID manually.

    Either change it for only one like that:

    //clone first element with new id
    clone = $("#selection").clone();
    clone.attr("id", newId);
    clone.find("#select").attr("id","whateverID");
    

    Or change all children using something like that: jQuery changing the id attribute of all the children

提交回复
热议问题