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

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条回答 默认 最新

  • 斯洛文尼亚旅游 2017-04-09 05:24
    关注

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

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

报告相同问题?