为什么我这个鼠标移上去透明度没有反应,可以帮我看一下吗?
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<style>
div{
background:red;
width:200px;
height:200px;
filter:alpha(opacity:30);
opacity:0.3;
margin:30px;
}
</style>
<script>
window.onload = function () {
var div = document.getElementsByTagName("div");
for(var i=0;i<div.length;i++){
div[i].alpha = 30;
div[i].timer = null;
div[i].onmouseover = function () {
start(this,100);
};
div[i].onmouseout = function () {
start(this,30);
};
}
};
function start(obj,target){
var speed = 0;
clearInterval(obj.timer);
obj.timer = setInterval(function () {
if(obj.alpha > target)
{ speed = -10;}
else
{ speed = 10;}
if(target == obj.alpha)
{clearInterval(obj.timer);}
else{
obj.alpah += speed;
obj.style.filter = "alpha(opacity:" + obj.alpah + ");";
obj.style.opacity = obj.alpha/100;
}
},30);
}
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
</body>
</html>