JSFiddle - React, Tailwind, and code Playground

by path411

HTML

<div id="mydiv">I want this text <span>but not this text</span></div>

JavaScript

var mydiv = document.getElementById('mydiv');
    var text = Array.prototype.map.call(mydiv.childNodes, function(){
        return (this.nodeType == 3 ? this.textContent : ""); 
    }).join('');
        document.write(text);