zoukankan      html  css  js  c++  java
  • 点击每一个button,弹出相应的索引号

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>


    </head>

    <body>
    <div class="btn">
        <input type="button" value="0" />
        <input type="button" value="1" />
        <input type="button" value="2" />
        <input type="button" value="3" />
        <input type="button" value="4" />
        <input type="button" value="5" />
        <input type="button" value="6" />
        <input type="button" value="7" />
        <input type="button" value="8" />
        <input type="button" value="9" />
        <input type="button" value="10" />
    </div>
    </body>

    <script type="text/javascript">
    var oBtn=document.getElementsByTagName('input');
    for(var i=0;i<oBtn.length;i++){
     (function(i){
     oBtn.item(i).onclick=function(){
      alert(i)
      }
     })(i)
     }

    </script>
    </html>

  • 相关阅读:
    OpenCV && C++ 01
    图像矩的理解
    Halcon Example
    LabVIEW
    Working Experience
    Working Experience
    Working Experience
    C++
    Trigger,Cursor
    Paging
  • 原文地址:https://www.cnblogs.com/xiaoleidiv/p/3341135.html
Copyright © 2011-2022 走看看