设值
element.textContent = “text”;
取值
var text = element.textContent;
区别
textContent和innerText类似,也会同时获取子元素的text content,比如
<div>this is <span>a</span> text!</div>
// div.textContent == "this is a text!"
•textContent会获取所有元素的content,包括`<script>`和`<style>`元素
•innerText不会获取hidden元素的content,而textContent会