jquery move element to last child position

前端 未结 6 483
迷失自我
迷失自我 2021-01-01 10:40

Let\'s say I have a

that contains some random elements, but there is one element I\'ve created with this unique selector : $(\'.myUniqueElemen
6条回答
  •  盖世英雄少女心
    2021-01-01 11:25

    There is no need to use .insertAfter. You should also not use .clone as it'll remove any attached data or events, unless you use .clone(true).

    Simply use .appendTo to add the target element to the div and it'll get detached from its original position and added as the last child of the div:

    $('.myUniqueElement').appendTo('#my-div');
    

提交回复
热议问题