我有 3.a和一个函数,它应该在-ed时提醒数字 [0, 1 or 2].a所属mouseover的数字:
function a(){
for(var c=0; c<3; c++){
alert(c);
$('.a:eq('+c+')').mouseover(function(){alert(c)});
}
}
当我执行它时,第一个alert(c)被触发了三次,消息分别为“0”、“1”、“2”,正如预期的那样。
但是,当 时mouseover .a,无论.a是哪个,都会提示“3”。
如果有人能解释为什么会发生这种情况并提供解决方案,我将不胜感激。