透明度没有改变
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0px;
padding: 0px;
}
#div1{
width: 200px;
height: 180px;
background: red;
filter: alpha(opacity:30);
opacity: 0.3;
}
</style>
<script>
window.noload=function(){
var odiv=Document.getElementById('div1');
odiv.onmouseover=function(){
starmove(100);
}
odiv.onmouseout=function(){
starmove(30);
}
}
var timer = null;
var alpha=30;
function starmove(iTarget){
var odiv = Document.getElementById('div1');
clearInterval(timer);
timer = setInterval(function(){
var speed=0;
if (alpha>iTarget) {
speed=-10;
}else{
speed=10;
}
if (alpha==iTarget){
clearInterval(timer);
}else{
alpha+=speed;
// odiv.style.filter='alpha(opacity:'+alpha+')';
odiv.style.filter = "alpha(opacity:‘+alpha+')";
odiv.style.opacity = alpha/100;
}
},30)
}
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>