智能社区运动:使用setInterval开启多个定时器探讨.pdfVIP

  • 3
  • 0
  • 约1.06万字
  • 约 12页
  • 2026-03-20 发布于北京
  • 举报

智能社区运动:使用setInterval开启多个定时器探讨.pdf

开调用setInterval会开启多个定时器

!DOCTYPEHTML

htmllangzh‑CN

headmetacharsetUTF‑8title/titlestyletype

text/css#s_div{position:absolute;top:123px;left:120px;

background:red;width:150px;height:150px;}/style

scripttypetext/javascriptwindow.onload=function(){

varmybtn=document.getElementById(start);

mybtn.onclick=function(){startMove();}}function

startMove(){vars_div=document.getElementById(s_div);

vartimer=null;timer=setInterval(function(){varspeed

=3;//物体左偏移量if(s_div.offsetLeft=300){

clearInterval(timer);}else{//移动,物体的左偏移offsetLeft

+speeds_div.style.l

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档