Answers for "how to strip tags in javascript"

9

javascript strip html tags from string

var htmlString= "<div>\n <h1>Hello World</h1>\n <p>This is the text that we should get.</p>\n <p>Our Code World &#169; 2017</p>\n </div>";

var stripedHtml = htmlString.replace(/<[^>]+>/g, '');
var decodedStripedHtml = he.decode(stripedHtml);

// Hello World
// This is the text that we should get.
// Our Code World &#169; 2017
console.log(stripedHtml);

// Hello World
// This is the text that we should get.
// Our Code World © 2017
console.log(decodedStripedHtml);
Posted by: Guest on February-18-2020
1

js strip_tags

let strippedString = originalString.replace(/(<([^>]+)>)/gi, "");
Posted by: Guest on October-08-2020
1

how to strip html tags in javascript

function stripHtml(html)
{
   let tmp = document.createElement("DIV");
   tmp.innerHTML = html;
   return tmp.textContent || tmp.innerText || "";
}
Posted by: Guest on March-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language