Home  >  Q&A  >  body text

javascript - 新人求助JS出现SyntaxError: missing ; before statement错误;

我想要的效果是,能够获取p里面的li的数量。
但浏览器提示我SyntaxError: missing ; before statement错误这个。在百度上找了好多都没找到合适的解答,求大神们帮帮小弟。小弟是新人哈。

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>CSS换肤功能</title>
    <style>
        ul{
            width: auto;
            height: auto;
            background-color:#205ec1;
            padding: 20px 0px 20px 10px;
        }
        ul li{
            width: 100px;
            height: 100px;
            background-color: #fa8b1c;
            margin-top: 20px;
            margin-bottom: 10px;
        }
    </style>
    <script>
        window.onload function(){
            var odii=document.getElementById("sefk");
            var ods=document.getElementById("op");
            var acd=ods.getElementsByTagName("li");
            oddi.onclick=function(){
                alert(acd.length);
            }
        }
    </script>
</head>
<body>
  <input type="button" value="按钮" id="sefk" />


<p id="op">
    <ul>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
    </ul>
  </p>


</body>
</html>
PHP中文网PHP中文网2749 days ago585

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-10 14:59:01

    /*忘了写赋值操用符了吧*/
    window.onload = function(){...}
    

    reply
    0
  • Cancelreply