js获取元素的innerText属性为什么为空

看这样一段内容:

<div id="ii" style="visibility:hidden">
    <a style="cursor: hand">{0}/{1}</a>
    <a style="cursor: hand">[首页]</a>
    <a style="cursor: hand">[上页]</a>
    <a style="cursor: hand">[下页]</a>
    <a style="cursor: hand">[末页]</a>
    <input style="width: 20px; height: 16px" id="Text1">
</div>
<script>
    var a = document.getElementById("ii").children[0];
    document.write(a.innerHTML + " + " + a.innerText);
</script>

在ff浏览器因为没有支持innerText所以自然无法使用,chrome浏览器中a标签的innerText属性是没有办法获取的,原因就是它的父级div将visibility设置为了hidden(而display:none并不影响chrome的innerText取值),那么在IE浏览器中仍然是可以获取的!!!

posted @ 2016-08-26 14:36  soft.push("zzq")  Views(3395)  Comments(0Edit  收藏  举报