79694147

Date: 2025-07-08 11:28:13
Score: 1
Natty:
Report link

In my case, the accepted answer didn't work, since if there was no text in the current node it would return the text of a sub node.

This works:

$(element).clone().children().remove().end().text()
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Ryan Noonan