js--提高
<script type="text/javascript"> function fn(){ console.log("test"); } window.onload=function(){ var btns=document.getElementsByTagName("input"); for(var i = 0;i<btns.length;i++){ btns[i].index=i; btns[i].onclick=function(){ //alert(btns[i].value); alert(this.index); } } } </script> <body> <input type="button" value="btn1" > <input type="button" value="btn2" > <input type="button" value="btn3" > <input type="button" value="btn4" > <input type="button" value="btn5" > </body>
今日事今日毕