/** * 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)}
添加回答
举报
0/150
提交
取消