Answers for "convert html to text javascript"

4

js convert html to text

// To remove all HTML tags use the ".replace(/<[^>]+>/g, '')" method.
let myHTML= "<div><h1>Jimbo.</h1>\n<p>That's what she said</p></div>";
let strippedHtml = myHTML.replace(/<[^>]+>/g, '');
console.log(stripedHtml); // Jimbo. That's what she said
Posted by: Guest on September-06-2021
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
0

js text to html

var textToHTML= function (str) {

	var dom = document.createElement('div');
	dom.innerHTML = str;
	return dom;

};
Posted by: Guest on November-06-2021

Code answers related to "convert html to text javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language