jquery move element to last child position

前端 未结 6 439
迷失自我
迷失自我 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:24

    This is my solution and I think this is the best way I can use .insertAfter():

    HTML:

    unique
    item
    item
    item

    jquery:

    $('#b').on('click',function(){
        $('.myUniqueElement').insertAfter($('.p :last-child'))
    });
    

    The point is :last-child and this is the fiddle: http://jsfiddle.net/silverlight/RmB5K/3/

提交回复
热议问题