How to remove text inside an element with jQuery?

后端 未结 3 1263
鱼传尺愫
鱼传尺愫 2020-12-15 22:40

I have a script that creates a list of items with a structure like this:

  • Some stuff
  • 3条回答
    •  -上瘾入骨i
      2020-12-15 23:16

      $('li').not('div,a').text('') 
      

      Try this, untested

      Edit

      $('li').contents().filter(function(){ return !(this.tagName == 'DIV' 
                                                  || this.tagName == 'A');}).remove();
      

    提交回复
    热议问题