首页 > 代码库 > 用js实现动画[采他山之石进行改善,感谢]

用js实现动画[采他山之石进行改善,感谢]

原文:http://www.cnblogs.com/thinkgao/p/3333491.html

以下是我改善的代码:

<!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>
#animation{
width:500px;
height:500px;
background-color:#f00;
}
</style>
</head>

<body>
<div id="animation"></div>
<script>
(function(){
var someAnimation=function (thenode,args){
thenode.style.opacity=args;
};
var animation=document.getElementById("animation");
var todoFunc=function(pos){
return function(){
someAnimation(animation,pos);
}
};
setInterval(function(){
for(var i=0;i<10;i+=1){
setTimeout(todoFunc(i/10),i*100);
}
},2000);
})();
</script>
</body>
</html>

用js实现动画[采他山之石进行改善,感谢]