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()