我想在隨機時間間隔內做一個隨機函數。 這裏是代碼:在隨機時間間隔內做隨機函數(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但這仍然不起作用! :) –