jquery 页面循环倒计时

<html>
    <head>
<script type="text/javascript" src="jquery.js"></script>



<script type="text/javascript"> function countDown(secs){ var $n1 = $("#n1"); // 输出n1的当前坐标 var coord = $n1.offset(); var $jumpTo =$("#jumpTo"); //alert(jumpTo); $jumpTo.text(secs); if(--secs>0){ setTimeout("countDown("+secs+")",1000); } else{ var offset = $n1.offset( {top: coord.top, left: coord.left+30}); setTimeout("countDown("+3+")",1000); } } </script> 

    </head>

    <body>
 <span id="jumpTo">3</span> 
  <p onclick="countDown(3)">test</p>
<p id="n1" style="width:300px; height: 100px; background-color: red;">111</p>

    </body>
</html>

你可能感兴趣的:(jquery)