1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <script type="text/javascript">
var anim1, anim2
var pos = 0
function move1(){
document.getElementById('foo1').style.left=pos+"px"
pos=pos+10;
}
function move2(){
document.getElementById('foo2').style.left=pos+"px"
}
function bar(){
anim1=setInterval(function(){new move1()},2000);
setTimeout(function(){
anim2=setInterval(function(){new move2()},2000)},1000);
}
</script>
<style type="text/css">
div {position:absolute;
left:0;
height:100px;
width:100px;
}
#foo1 { top: 10px;
background-color:red;}
#foo2 { top: 210px;
background-color:green;}
</style>
</head> |