1var htmlString= "<div>\n <h1>Hello World</h1>\n <p>This is the text that we should get.</p>\n <p>Our Code World © 2017</p>\n </div>";
2
3var stripedHtml = htmlString.replace(/<[^>]+>/g, '');
4var decodedStripedHtml = he.decode(stripedHtml);
5
6// Hello World
7// This is the text that we should get.
8// Our Code World © 2017
9console.log(stripedHtml);
10
11// Hello World
12// This is the text that we should get.
13// Our Code World © 2017
14console.log(decodedStripedHtml);
1function stripHtml(html)
2{
3 let tmp = document.createElement("DIV");
4 tmp.innerHTML = html;
5 return tmp.textContent || tmp.innerText || "";
6}
7