想将用getElementsByTagname获得的元素通过绑定click事件来放到变量selected中,但是提示 error:Don't make functions within a loop
感觉好奇怪.....循环里不能绑定事件吗?
查了一下,这是闭包的问题吗??
if (select&&select.length) {
for(var i=0,len=select.length;i
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
是闭包的问题,回调函数里不要有循环变量
i用事件委托性能好太多