Home >Web Front-end >JS Tutorial >js setinterval method to modify the running time period

js setinterval method to modify the running time period

小云云
小云云Original
2018-05-16 14:36:513260browse

Can I modify the running setInterval time? In fact, it is possible. This article will share with you the method of modifying the running time period with js setinterval. I hope it can help you.

function setDeceleratingTimeout(callback, factor, times){
    var internalCallback = function(tick, counter) {
        return function() {
            if (--tick >= 0) {
                window.setTimeout(internalCallback, ++counter * factor);
                callback();
            }
        }
    }(times, 0);

    window.setTimeout(internalCallback, factor);};// console.log() requires firebug  
      setDeceleratingTimeout(function(){ console.log('hi');
      }, 10, 10);setDeceleratingTimeout(function(){ console.log('bye'); }, 100, 10);

Related recommendations:

javascript implementation code to determine time period

How does mysql obtain statistics within a specified time period? Detailed explanation of data code

PHP gets the year, month, day, hour, minute, second between the specified time period, php gets_PHP tutorial

The above is the detailed content of js setinterval method to modify the running time period. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn