Skip to content Skip to sidebar Skip to footer

Changing Multiple Images

I've been having problems recently with a piece of code that I have been working on. I am asked to create an array and cycle through the traffic lights with a button, this is what

Solution 1:

Images don't have innerHTML, try this :

document.getElementById("image").src = images[0];

Solution 2:

You need to set the src attribute.

<img src="" />
<!---^^^^^^---- You need to setthis to make this work.

Replace all the:

document.getElementById("image").innerHTML=images[0];

With the following format:

document.getElementById("image").src = images[0]);

Post a Comment for "Changing Multiple Images"