How to select an element's parent and the parent's siblings

后端 未结 7 1409
花落未央
花落未央 2020-12-08 12:53

I have this code:

$(\"#test\").siblings(\'p\').remove();
$(\"#test\").remove();

How can I chain this code instead of writing it separately?

相关标签:
7条回答
  • 2020-12-08 13:48
    $("#text").siblings('p').remove().prevObject.remove();
    

    edit: Though this works, don't do this. as Matt's comment says, prevObject is undocumented

    0 讨论(0)
提交回复
热议问题