<!doctype?html>
<html>
<head><meta?charset="utf-8">
<title>無標題文檔</title>
</head>
<script?type="text/javascript">
????window.onload=function(){
????????for(var?i=1;i<=2;i++){
????????????document.getElementById("b"+i).addEventListener("click",function(){alert(i);},false);
????????}
????}
????</script>
????<body>
????<button?id="b1">button1</button>?<button?id="b2">button2</button>
</body>
</html>
對JavaScript中的一段代碼不是那么理解,求解釋,為什么彈出的窗口是3?
慕哥4957459
2018-05-24 11:42:11