为什么我的代码没有反应呢?

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

div{

width: 200px;

height: 200px;

background: red;

filter: alpha(opacity:30);

opacity: 0.3;

margin: 10px;

float: left;

}

</style>

</head>

<body>

<script type="text/javascript">

window.onload=function(){

var odiv=document.getElementsByTagName('div');

for(var i=0;i<odiv.length;i++){

odiv[i].alpha=30;

odiv[i].timer=null;

odiv[i].onmouseover=function(){

startMove(this,100);

}

odiv[i].onmouseout=function(){

startMove(this,30);

}

}


}


function startMove(obj,iTarget){

clearInterval(obj.timer);

if(alpha>iTarget){

speed=-10;

}else{

speed=10;

}

obj.timer=setInterval(function(){

if(alpha==iTarget){

clearInterval(obj.timer);

}else{

alpha+=speed;

obj[i].style.filter='alpha(opacity:'+alpha+')';

obj[i].style.opacity=alpha/100;

}

},30)

}

</script>

<div></div>

<div></div>

<div></div>

<div></div>

</body>

</html>


Richardson
浏览 1243回答 1
1回答

不断滴自我催眠

alpha is undefined
打开App,查看更多内容
随时随地看视频慕课网APP