zoukankan      html  css  js  c++  java
  • 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=" 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浏览器中仍然是可以获取的!!!

  • 相关阅读:
    python爬虫
    RMQ算法
    组合数
    水池数目
    jQuery 拼接事件
    ORACLE
    day 75
    day74 vue框架
    day73 vue框架
    day 72 vue框架
  • 原文地址:https://www.cnblogs.com/zzq-include/p/5810270.html
Copyright © 2011-2022 走看看