How to clear interval and set it again?

前端 未结 5 1139
离开以前
离开以前 2020-12-30 03:15

This is what i am trying to accomplish: when the last slide is reached fadeOut last slide and then fadeIn first slide, and then clearInterval (everything works with th

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 03:48

    Just Example

    var myVar 
    function myTimer() {
        var d = new Date();
        var t = d.toLocaleTimeString();
        document.getElementById("demo").innerHTML = t;
    }
    
    function myStopFunction() {
        clearInterval(myVar);
    }
    function myStartFunction() {
        myVar = setInterval(myTimer, 1000);
    }
    myStartFunction();

提交回复
热议问题