Using .text() to retrieve only text not nested in child tags

后端 未结 25 1752
隐瞒了意图╮
隐瞒了意图╮ 2020-11-21 05:55

If I have html like this:

  • This is some text First span text
  • 相关标签:
    25条回答
    • 2020-11-21 06:55

      If the position index of the text node is fixed among its siblings, you can use

      $('parentselector').contents().eq(index).text()
      
      0 讨论(0)
    提交回复
    热议问题