我想在随机时间间隔内做一个随机函数。 这里是代码:在随机时间间隔内做随机函数(JQUERY)
function numberOne() {
$("#here").hmtl("numberOne");
}
function numberTwo() {
$("#here").hmtl("numberTWO");
}
var randomfunction = [numberOne, numberTWO]
var randomfunction = randomfunction[Math.floor(Math.random() * randomfunction.length)];
(function loop() {
var rand = Math.round(Math.random() * (1000 - 500)) + 500;
setTimeout(function() {
randomfunction();
loop();
}, rand);
}());
它不起作用。我不知道为什么。你能帮我解释一切错误吗?谢谢!
*“它不工作” *如“无法甚至运行”,“运行,但在某些时候爆炸”,“运行,但不会做什么我期望“,或者......? – kryger
我知道有.hmtl但这仍然不起作用! :) –