用JavaScript实现动画效果(2)

2005-07-28 17:51:10  作者:  来源:中国站长学院   文字大小:】【】【
  </head>
  <body>
  <div id="div1" style="visibility:visible; position:absolute; left:10; top:10; z-index:1;">
   <table bgColor="#FFFFCC" border="1"cellPadding="0" cellSpacing="0">
    <tr>
     <td>I can moving...</td>
    </tr>
   </table>
  </div>

  <br><br>
  <input type="button" value="开始移动" onClick="startMove()">
  <input type="button" value="停止移动" onClick="stopMove()">

   </body>
  </html>
 

  这里主要使用了一个叫setTimeout(function, interval)函数,这个函数的参数格式为:
  第一个参数“function”为超时后调用的函数名,第二个参数“interval”为超时值,以微秒为单位。

  注意一点是如果要停止这个计时器,必须保存调用这个setTimeout()函数后的返回值,通过clearTimeout(id)函数来取消计时器。



相关文章