为什么鼠标移出的时候,透明度变回0.3,还在一直向上走???用的Google浏览器,而且我发现filter并没有执行
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
padding: 0;
margin: 0;
}
/*练习21*/
#div1{
width: 200px;
height: 200px;
background: red;
filter: alpha(opacity:30);
opacity: .3;
}
</style>
<script>
window.onload = function(){
var oDiv = document.getElementById("div1");
oDiv.onmouseover = function(){
startMove(100);
}
oDiv.onmouseout = function(){
startMove(30);
}
var timer = null;
var alpha = 30;
function startMove(iTarget){
var oDiv = document.getElementById("div1");
clearInterval(timer);
timer = setInterval(function(){
var speed = 0;
if(speed > iTarget){
speed = -10;
}else{
speed = 10;
}
if(alpha == iTarget){
clearInterval(timer);
}else{
alpha+=speed;
oDiv.style.filter = 'alpha(opacity: '+alpha+')';
oDiv.style.opacity = alpha/100;
}
},30)
}
}
</script>
</head>
<body>
<!--练习21 透明度-->
<div id="div1"></div>
</body>
</html>