我之前就如何使用我的 javascript 代码修复某些问题寻求帮助,我现在已经修复了,但是我的代码有问题吗?因为最后一个阵列保持开启的时间超过 1 秒,所以它会保持大约 5 秒的时间。这是因为我正在重置数组还是在 Javascript 中这是正常的?
function Background()
{
var Backgrounds = [
'#333', '#777', '#999', '#CCC'
],
Max_Backgrounds = Backgrounds.length,
Background_Stage = -1;// Yes, it's meant to be -1 so when background_stage++; is called it will make it 0 thus start at the beginning of the array.
setInterval(function() {
if(Background_Stage >= Max_Backgrounds) Background_Stage = -1;
$('body').css('background', Backgrounds[Background_Stage++]);
}, 1000);
}