匿名函数问题
window.onload = function(){ var myLi = document.getElementsByName('my'); for(var i = 0;i<myLi.length;i++){ myLi[i].onmouseover = function(){ this.style.background = "red"; //myLi[i].style.background = "red";//这个为什么不能用,myLi[i]是空 } } }
window.onload = function(){ var myLi = document.getElementsByName('my'); for(var i = 0;i<myLi.length;i++){ myLi[i].onmouseover = function(){ this.style.background = "red"; //myLi[i].style.background = "red";//这个为什么不能用,myLi[i]是空 } } }
2017-12-23
举报