innerText和textContent区别对比实例页面
回到相关文章 »效果:
一段文字内容...
我后面有一段隐藏文字,就是我啦!
代码:
HTML代码:
<p id="dom">一段文字内容<span style="position:absolute;">...</span></p>
<button onClick="this.after(dom.innerText)">
innerText结果是?
</button>
<button onClick="this.after(dom.textContent)">
textContent结果是?
</button>
<p id="dom2">我后面有一段隐藏文字<span hidden>,就是我啦!</span></p>
<button onClick="this.after(dom2.innerText)">
innerText结果是?
</button>
<button onClick="this.after(dom2.textContent)">
textContent结果是?
</button>