jQuery: appendTo parent

前端 未结 4 2355
灰色年华
灰色年华 2021-02-19 02:59

I can\'t seem to get the appendTo to work. What do I do wrong?

$(\'div:nth-child(2n) img\').appendTo(parent);

Current markup:

&         


        
4条回答
  •  失恋的感觉
    2021-02-19 03:33

    You can use .prepend() instead of append Append insert at the end off a the parent. But prepend insert at the begin from the parent. so then like:

    $('.container > p').each(function () {
        $(parent).prepend(this);
    });
    

提交回复
热议问题