Remove text with jQuery

Using the answer from this question:

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

Leave a Comment