Remove text with jQuery

jquery

Solution

Using the answer from this question:

$(elem)
  .contents()
  .filter(function() {
    return this.nodeType == 3; //Node.TEXT_NODE
  }).remove();

Problem

Is there a way to remove text that is not wrapped in any tag using jQuery ``` <p>This is some text</p> This is "unwrapped" text //to be removed <span>some more text</span> ``` Thank you for your help

Original source

Related problems