pull out only text from element javascript

JavaScript
function extractContent(html) {

    return (new DOMParser).parseFromString(html, "text/html") . 
        documentElement . textContent;

}

Source

Also in JavaScript: