关于alpha>iTarget的问题想问下大家
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>透明度</title>
<style>
*{
margin:0;padding:0;
}
#div{
width:300px;height:200px;background:red;filter:alpha(opacity:30);opacity:0.3;
}
</style>
</head>
<script>
window.onload=function(){
var onDiv=document.getElementById('div');
onDiv.onmouseover=function(){
startmove(100);
}
onDiv.onmouseout=function(){
startmove(30);
}
}
var timer=null;
alpha=30;
function startmove(iTarget){
var onDiv=document.getElementById('div');
clearInterval(timer)
timer=setInterval(function(){
var speed=0;
if(alpha>iTarget){
speed=-10;
}else{
speed=10;
}
if(alpha==iTarget){
clearInterval(timer);
}else{
alpha+=speed;
onDiv.style.filter='alpha(opacity:'+alpha+')';
onDiv.style.opacity=alpha/100;
}
},30)
}
</script>
<body>
<p id="div"></p>
</body>
</html>老师在讲alpha>iTarget我其实是有点懵的,因为我看了下已经定义了alpha=30,并且iTarget在30-100之间徘徊的,那我应该怎么去理解这句话?