JSFiddle - React, Tailwind, and code Playground

by Joshua Koudys

JavaScript

function stripTags(htmlstr) {
    var div = document.createElement('div');
    div.innerHTML = htmlstr;
    return div.textContent;
}

var pagebuffer = '<p>Here\'s some text with <em>tags</em> our <strong>CMS</strong> threw in there.</p>';

// Unsanitized
console.log(pagebuffer);

// Just the text
console.log(stripTags(pagebuffer));