JavaScript 元素简易动画

来源:互联网 发布:青岛优创数据怎么样 编辑:程序博客网 时间:2024/05/16 09:50
<p id="s">fly</p>

<script>

function move(){

var id=document.getElementById("s");

id.style.position="absolute";

if(!id.style.left){

id.style.left="200px";}

if(id.style.left){id.style.top="200px";}

id.style.color="red";
 
var x1=parseInt(id.style.left);

var y1=parseInt(id.style.top);

if(x1<500){x1++}

if(y1<450){y1++}

id.style.left=x1+"px";

id.style.top=y1+"px";

 setTimeout("move()",10);

}
move();
</script>
0 0
原创粉丝点击