为什么不能创建函数?
<script type="text/javascript" language="javascript">
window.onload =function(){
var aDiv = document.getElementsByTagName("div");
for (var i=0;i<aDiv.length;i++)
aDiv[i].alpha = 30;
aDiv[i].onmouseover = function(){
changes(this,100);
}
aDiv[i].onmouseout = function(){
changes(this,30);
}
}
function changes(obj,num){
clearInterval(obj.timer);
obj.timer = setInterval(function(){
var speed = 0;
obj.alpha>num?speed=-10:speed=10;
if(obj.alpha == num)
{
clearInterval(obj.timer);
}
else
{
obj.style.filter = "alpha(opacity:"+obj.alpha+speed+")";
obj.style.opactiy = (obj.alpha + speed)/100;
}
},30)
}
</script>
浏览器提示:Uncaught TypeError: Cannot set property 'onmouseover' of undefined
包括onmouseout也一样,不能创建。这是为什么?