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

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

If I have html like this:

  • This is some text First span text
  • 25条回答
    •  心在旅途
      2020-11-21 06:40

      $($('#listItem').contents()[0]).text()
      

      Short variant of Stuart answer.

      or with get()

      $($('#listItem').contents().get(0)).text()
      

    提交回复
    热议问题