Answers for "replace html text"

3

javascript remove html from text

//remove html tags from a string, leaving only the inner text
function removeHTML(str){ 
    var tmp = document.createElement("DIV");
    tmp.innerHTML = str;
    return tmp.textContent || tmp.innerText || "";
}
var html = "<div>Yo Yo Ma!</div>";
var onlyText = removeHTML(html); "Yo Yo Ma!"
Posted by: Guest on July-31-2019
3

html put newline in text with \n

white-space: pre-line;
Posted by: Guest on April-06-2020

Browse Popular Code Answers by Language