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


我想要的效果是,能够获取DIV里面的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("odiv");
            var acd=ods.getElementsByTagName("li");
            oddi.onclick=function(){
                alert(acd.length);
            }
        }
    </script>
</head>
<body>
  <input type="button" value="按钮" id="sefk" />


<div id="odiv">
    <ul>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
    </ul>
  </div>


</body>
</html>

JavaScript

Shrori 9 years, 2 months ago

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

wycsos answered 9 years, 2 months ago

Your Answer