何-小鱼 2017-04-09 02:56 采纳率: 80%
浏览 1808
已采纳

javascript中为什么getElementsByTagName返回数组长度为0?

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Document</title>
    <script type="text/javascript" src="javascript/display_abbr.js"></script>
    </head>
    <body>
        <h1>What is the Document Object Model?</h1>
        <p>The <abbr title="World Wide Web Consortium">W3C</abbr> defines the <abbr title="Document Object Model">DOM</abbr> as:</p>
        <blockquote cite="http://www.w3.org/DOM/">
            <p>A platform- and language-neutral interface that will allow programs and script to dynamiclly access and update the content,structure and style of documents.</p>
        </blockquote>
        <p>It is an <abbr title="Application Programming Interface">API</abbr> that can be used to navigate <abbr title="HyperText Markup Language">HTML</abbr> and <abbr title="eXtensible Markup Language">XML</abbr> documents.</p>

  • 写回答

3条回答 默认 最新

  • Go 旅城通票 2017-04-09 05:24
    关注

    你是直接执行displayAbbreviations函数将返回值作为onload事件处理函数,你放dom上面肯定获取不到了

     window.onload = displayAbbreviations//////////();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建