Run a function in time interval in jQuery

后端 未结 4 1585
借酒劲吻你
借酒劲吻你 2020-12-03 17:21

I want to make a banner by using jQuery. When the page loaded script will show a group of photos one by one. For example, the controller sends 10 photos and each photo will

4条回答
  •  天涯浪人
    2020-12-03 17:48

    The main method is:

     setInterval(function () {
            console.log('it works' + new Date());
        },30000);
    

    If you need to clear interval in future:

    var myInterval = setInterval(function () {
                console.log('it works' + new Date());
            },30000); 
    

    in the future:

    clearInterval(myInterval);
    

提交回复
热议问题