Menu
The webpage needs to cycle four images, without user input (like an animation or slideshow).
This is my current code:
<!DOCTYPE html>
<html>
<body onload=”setTimeout(firstImage, 3000)”;
<h1> Traffic lights </h1>
<p> Please click the button to change the lights. </p>
<img id=”trafficLight” src=”red.jpg”>
<script>
var light = [“red.jpg” ,”redandamber.jpg” ,”green.jpg” ,”amber.jpg”,];
var index = 0;
function firstImage() {
index = index + 1;
var image = document.getElementById(‘trafficLight’);
image.src=light[index];
}
</script>
</body>
</html>
Any help is greatly appreciated! x