Jquery实现定时执行操作setInterval和clearInterval、setTimeout函数

崔博伦一路有你 2014-08-06

1.setInterval()用法:

var idInt = setInterval(function(){},2000);

 2.clearInterval用法:

clearInterval(idInt);

另,通过setTImeOut()也可以设置定时操作,具体demo如下:

function viewInExplorerStatus() {  
  var date = new Date();  
  s = date.getYear() + "年" +   
      (date.getMonth()+1) + "月" +   
      date.getDate() + "日" +   
      date.getHours() + "点" +   
      date.getMinutes() + "分" +   
      date.getSeconds() + "秒";  
  if (!Flag) {  
    s = "";  
  }  
  window.status = "欢迎您,User !  当前在线人数:8.当前时间:" + s;
  setTimeout("viewInExplorerStatus();", 1000);  
}

相关推荐

89500297 / 0评论 2019-12-04