/** * Created by jgy on 2017/7/25. */window.onload=function () { ? ?var Odiv=document.getElementById('div1'); ? ?Odiv.onmouseover=function () { ? ? ? ?startMove(100); ? ?} ? ?Odiv.onmouseout=function () { ? ? ? ?startMove(30); ? ?}}var timer=null, ? ?alpha=30;function ?startMove(iTarget) { ? ?clearInterval(timer); ? ?var Odiv=document.getElementById('div1'); ? ?timer=setInterval(function () { ? ? ? ?var speed=0; ? ? ? ?if(iTarget>alpha){ ? ? ? ? ? ?speed=10; ? ? ? ?}else { ? ? ? ? ? ?speed=-10; ? ? ? ?} ? ? ? ?if(alpha==iTarget){ ? ? ? ? ? ?clearInterval(timer); ? ? ? ?}else { ? ? ? ? ? ?alpha+=speed; ? ? ? ? ? ?Odiv.style.filter='alpha(opacity:'+alpha+')'; ? ? ? ? ? ?Odiv.opacity=alpha/100; ? ? ? ?} ? ?},30)}
為啥出不來漸變的效果
xiaojidream1314
2017-07-25 11:06:44