吃瓜小夏
2016-05-10 12:48
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>普通速度动画</title>
<style type="text/css">
*{margin:0;padding:0;}
div{width:100px;height:100px;background-color:#C00;position:relative;left:0px;top:0;opacity:0.3;filter:Alpha(opacity=30);}
</style>
<script type="text/javascript">
window.onload=function(){
var mdiv=document.getElementById("wrapper");
mdiv.onmouseover=function(){startmove(100)};
mdiv.onmouseout=function(){startmove(30)};
}
var timer=null;
var alpha=30;
function startmove(itarget){
var mdiv=document.getElementById("wrapper");
clearInterval(timer);
timer=setInterval(function(){
var speed=0;
if(alpha>itarget){speed=-10;}
else{speed=10;}
if(alpha==iterget){clearInterval(timer)}
else{alpha+=speed;mdiv.style.opacity=alpha/100;mdiv.style.filter="Alpha(opacity:'+alpha+')"}
},30)
}
</script>
</head>
<body>
<div id="wrapper">
<span id="span">微信</span>
</div>
</body>
</html>
不好意思 自己已经检查出问题在哪了 最后的itarget拼写错误了 哎 太粗心大意了
JS动画效果
113920 学习 · 1500 问题
相似问题