<body>
<div id="div1">1</div>
<div id="div2">2</div>
<div id="div3">3</div>
<script>
$(document).ready(function(){
var boxNumber=1;
while(boxNumber<=3){
$('#div'+boxNumber).click(function(){
alert(boxNumber);
});
boxNumber++;
}
});
</script>
</body>
我希望代码在我单击它时提醒它的框号,但它却提醒了数字 4。我如何解决它?谢谢