此代碼我在某種程度上有效;它會改變,但速度很快,我希望在3秒左右後改變,但我無法找到如何改變。提前致謝!HTML [JAVASCRIPT]中的圖像在幾秒鐘後更改
CODE:
<img id = "theImage" src="red.jpg" alt="HTML5 Icon" style="width:250px;height:500px;" align = left>
<script>
var sequence = ["red.jpg", "red&amber.jpg", "green.jpg", "amber.jpg"];
var place = 0;
setInterval(change_light,1);
function change_light() {
place += 1;
if (place > sequence.length -1) {
place = 0;
}
document.getElementById('theImage').src = sequence[place];
}
如果您決定出現問題,請標記正確答案 – Antonio