Changing the interval of SetInterval while it's running

后端 未结 16 1373
南旧
南旧 2020-11-22 07:35

I have written a javascript function that uses setInterval to manipulate a string every tenth of a second for a certain number of iterations.

function timer(         


        
16条回答
  •  感动是毒
    2020-11-22 08:21

    Make new function:

    // set Time interval
    $("3000,18000").Multitimeout();
    
    jQuery.fn.extend({
        Multitimeout: function () {
            var res = this.selector.split(",");
            $.each(res, function (index, val) { setTimeout(function () { 
                //...Call function
                temp();
            }, val); });
            return true;
        }
    });
    
    function temp()
    {
        alert();
    }
    

提交回复
热议问题