我遇到这样的问题:
<div id='stickyid' style='display:block; color:red'>happi</div>
After write :
<script type="text/javascript">
var thevalue = document.getElementById("stickyid").innerText;
document.write(""+thevalue+"");
</script>
它在Chrome上运行正常但在Firefox和IE上运行不正常。我该如何解决?
答案 0 :(得分:5)
尝试:
var thevalue = document.getElementById("stickyid").innerText || document.getElementById("stickyid").textContent;
答案 1 :(得分:2)
var thevalue = document.getElementById("stickyid").textContent;