问题:有十个按钮点击按钮aler按钮的序号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>有十个按钮点击按钮aler按钮的序号</TITLE>
</HEAD>
<BODY>
<input type="button" />
<input type="button" />
<input type="button" />
<input type="button" />
<input type="button" />
<input type="button" />
<input type="button" />
<input type="button" />
<input type="button" />
<input type="button" />
</BODY>
</HTML>
<script type="text/javascript">
var buttons = document.getElementsByTagName("input");
for(var i = 0; i < buttons.length; i++){
buttons[i].addEventListener("click", (function(i){
return function(){
alert(i+1);
}
})(i));
}
</script>