这就是我要做的......
alert(document.getElementById('test').innerHTML);
<div id="test">
hi..my name is <div>Soul</div> and I am <strong>23 years old</strong>
Thank you.
</div>
警告框将显示:
hi..my name is <div>Soul</div> and I am <strong>23 years old</strong>Thank you.
但我在ALERT BOX中想要的是:
hi..my name is Soul and I am 23 years old Thank you.
答案 0 :(得分:3)
使用 textContent
代替 innerHTML
获取文字内容而不是标记
<div id="test">
hi..my name is <div>Soul</div> and I am <strong>23 years old</strong>
Thank you.
</div>
&#13;
{{1}}&#13;