javascript setinterval with random time -
i have setinterval function alert: setinterval(function(){ alert('oo'); }, 5000); but change (5000) interval each time interval runs alert() - i'd have randomly selected between 5 - 10 seconds. idea how it? you should use settimeout set interval after function should executed. function myfunction() { var min = 5, max = 10; var rand = math.floor(math.random() * (max - min + 1) + min); //generate random number between 5 - 10 alert('wait ' + rand + ' seconds'); settimeout(myfunction, rand * 1000); } myfunction()