通过 addeventListener() 添加的函数只执行了一次?··· box1.addEventListener('mouseover',test(2)); function test(i){
console.log(i);
}···为什么一打开网页控制台就输出 2 并且再次将鼠标悬停在上面的时候并不会输出 2如果代码这样写:··· box1.addEventListener('mouseover',test); function test(){ console.log(2);
}···一打开网页并不会直接输出 2 而是当鼠标悬停在该盒子上才输出,并且每次悬停都会输入一个 2,在这里 test(i) 和 test 有什么区别?
添加回答
举报
0/150
提交
取消