为什么点击圆圈不能弹出第几个圆圈的标记

解决方案 »

  1.   

    click拼错了吧
      

  2.   

    getElementsByTagName是多个的所以要加下标window.onload = function(){
    Li = document.getElementsByTagName("div")[0].getElementsByTagName("li");
    LiLength = Li.length;
    for(let i=0;i<LiLength;i++){
    Li[i].index = i;
    Li[i].onclick = function(){
    var index = this.index;
    alert(index);
    };
    }
    }
      

  3.   

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
            
            *{
                margin: 0;
                padding: 0;
            }
            div{
                height:100px;
                width: 550px;
                border:1px solid black;
                line-height: 100px;
                position: relative;
            }
            li{
                border:1px solid black;
                list-style: none;
                display: block;
                height: 100px;
                width: 100px;
                border-radius:50px 50px;
                float: left;
            }
        </style>
        <script>
            window.onload = function(){
                Li = document.getElementsByTagName("div").getElementsByTagName("li");
                Lilength = Li.length;
                for(let i =0;i<Lilength;i++){
                    Li[i].index = i;
                    Li[i].onclick = function(){
                        var index = this.index;
                        alert(index);
                }
            }
            }
           
        </script>
    </head>
    <body>
        <div>
          <ul>
           <li class="round"></li>
           <li class="round"></li>
           <li class="round"></li>
           <li class="round"></li>
           <li class="round"></li>   
        </ul>
        </div>
    </body>
    </html>
      

  4.   

    li[i].onclink= function()是这个问题么