我创建了一个电子邮件链接,它会自动填充正文中的必要信息。但是,当我执行 .innerHTML 时,我得到的比我预想的要多一些。
我想要“2012 年 3 月:12-16”
我得到什么<B>March, 2012</B>: <FONT color=blue>12</FONT> - <FONT color=blue>16</FONT>
有没有办法获得没有 html 标签的innerHTML?
.value = undefined
.text = undefined
你要.textContent
在除旧版 IE 之外的所有 IE 中,以及.innerText
在 IE 中(
So, try:
string = (node.textContent===undefined) ? node.innerText : node.textContent;
EDIT:或者,直接使用 GGG 的清洁剂string = (node.innerText || node.textContent)
, since undefined
是假的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)