jquery remove removing from another element

前端 未结 4 1087
清酒与你
清酒与你 2021-01-23 15:58

According to here, jquery\'s remove function should work like so..

$(\'div\').remove(\'selector\'); 

Which I\'m trying in this example.

4条回答
  •  天涯浪人
    2021-01-23 16:20

    You're trying to remove something that is both div and p.unwanted. The filter in remove() is applied to the current set of nodes, which in this case is all div elements.

    Use the children set instead:

    $('div').children().remove('p.unwanted');
    

提交回复
热议问题