JS动画抖动

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

 <head>

  <title> New Document </title>

  <meta name="Generator" content="EditPlus">

  <meta name="Author" content="">

  <meta name="Keywords" content="">

  <meta name="Description" content="">

 </head>

<script type="text/javascript" src="http://luxury.bjhoutai.com/js/jquery-1.8.2.min.js"></script> 

 <body style="height:2000px;">

<div id="mrt0" style="width:20px; height:20px; background:#f00; position:fixed; left:50px; top:300px;"></div>

  <script>  

function action(){ 

var a = parseInt(Math.random()*(55-45+1)+45); 

var b = parseInt(Math.random()*(302-298+1)+298); 

$("div").animate({left:a+"px"},200); 

$("div").animate({top:b+"px"},200);  

/*$("div").fadeOut(50).fadeIn(50); */ 

}

setInterval("action()",400);  

  </script>

 </body>

</html>

posted @ 2015-04-23 11:20  mrt_yy  阅读(520)  评论(0编辑  收藏  举报