為什么arr[i].style.width=300+"px";中瀏覽器會Uncaught TypeError: Cannot read property 'style' of undefined
var arr=document.getElementsByTagName("li");
for(var i=0;i<arr.length;i++){
arr[i].onclick=function(){
setInterval(function(){
arr[i].style.width=300+"px";
},300);
}
}
2015-07-07
http://bbs.csdn.net/topics/340176862
2015-07-07
試一下這個
2015-07-07
2015-07-07
因為i此時是arr.length,這里是閉包的問題。