该函数showRandom
每 1000 毫秒执行一次,但我希望它每random
毫秒执行一次。有什么解决方案吗?谢谢!
var random = 1000;
setInterval(function() {random = randomizator(60000,200000);} ,1000);
setInterval(function() {showRandom(random);}, random);
function randomizator(a,b)
{
return Math.floor(Math.random()*b) + a;
}
function showRandom(random)
{
$('#test').text(random);
}
演示:jsFiddle