jquery remove list item where .text() = 'blabla'

后端 未结 3 941
后悔当初
后悔当初 2020-12-11 01:31

I have the following structure

  • something
  • ...
  • blabla
  • <
3条回答
  •  Happy的楠姐
    2020-12-11 01:56

    If you want to avoid removing lis containing blabla unless blabla is further nested, use this:

    $("ul li > a:contains('blabla')").parent().remove();

    Otherwise, the first li from this HTML will be removed even though "blabla" is not where you might be targeting it:

    • Some nested content here: Blablabla
    • Some text

提交回复
热议问题