首页 > Web开发 > 详细

js setTimeOut与setInterval学习

时间:2014-12-04 17:18:52      阅读:226      评论:0      收藏:0      [点我收藏+]

  表示一下,小天使在的话确实能给我好多提示。今天的题目是,qq空间刷新一页的时候会有查看更多的按钮,现在的问题是,模拟点击前三次的按钮,即加载三次。

表示两个都是小天使想出来的,不过记录一下,表示学习~~还有一个也是春春帮我改进了。

1,

  function refresh(){
    for(var i=0;i<3;i++){
      setTimeOut(update,i*1000);
    }
  }
  function update(){
    var button=getElementById(‘feeds_more_ic‘);
    button.click();
  }

2,

  var time=0;
  setInterval(aa(),1000);
  function aa(){
    time++;
    if(time<=3){
      console.log(time);
      document.getElementById("feeds_more_ic").click();
    }else{
    clearInterval(aa());
    }
  }

3,

  var time=0;
  aa();
  function aa(){
    time++;
    if(time<=3){
      console.log(time);
      document.getElementById("feeds_more_ic").click();
      setTimeout("aa()",1000);
    }
  }

//document.getElementById("feeds_more_ic") 选中的是查看更多按钮

 

js setTimeOut与setInterval学习

原文:http://www.cnblogs.com/echo-yaonie/p/4143231.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!