function extractContent(html) {
return new DOMParser()
.parseFromString(html, "text/html")
.documentElement.textContent;
}
示例
let result = extractContent('<p>Hello World</p>')
console.log(result) // 'Hello World'
标签:html,JS,HTML,result,World,文本,Hello
From: https://www.cnblogs.com/crispyChicken/p/17126179.html