54sword
2012-10-21 12:11:23 +08:00
//true 正面, false 反面
var card = ['false', 'false', 'false', 'false'];
var index = 0;
function startTurnCard() {
if (index == card.length) index = 0;
var time = 5000 * index;
setTimeout(function() {
card[index] = true;
console.log((index + 1) + "卡片被翻到正面");
setTimeout(function() {
card[index] = false;
console.log((index + 1) + "卡片被翻回反面");
index++;
startTurnCard();
}, 5000);
}, 5000 + time);
}
startTurnCard();
也尝试写了一下,看看是否正确。