jQuery move node out of its parent

后端 未结 3 1073
面向向阳花
面向向阳花 2020-12-06 19:30

I have this code:

  • SOME TEXT
3条回答
  •  再見小時候
    2020-12-06 19:50

    Try this:

    $('.list > li > a > img').each(function() {
        $(this).insertBefore($(this).parent());
    })
    

    Demo at http://jsfiddle.net/alnitak/3nEVz/

    EDIT I came up with a cleaner version:

    $('.list > li > a > img').each(function() {
        $(this).parent().before(this);
    })
    

提交回复
热议问题