I have tried many methods in order to get this to work however I just cant seem to get the image to change automatically in a set time, the code is:
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Task 3</h1>
<p>This is my Traffic Light script</p>
<img id="light" src="E:\A452\RED traffic light.jpg">
<script>
var list = [
"RED AMBER traffic light.jpg",
"GREEN traffic light.jpg",
"AMBER traffic light.jpg",
"RED traffic light.jpg"
];
var index = 0;
function changeLights() {
index ++;
if (index == list.length);
index = 0;
document.getElementById(light).src = list[index];
}
var timer = setInterval(changeLights,3000);
</script>
</body>
</html>
' 'it should begetElementById('light')