ChadTinkler ChadTinkler - 4 years ago
942 0

I need help adding a timer for my project nothing on the Internet helps me so I thought I would come here and ask.


Change the animation script so that the sequence of lights is displayed automatically on a timed basis without user input.

<!DOCTYPE html>

<h1>Javascript Task 3</h1>

<img id="myImage" onclick="lightChange()" src="Redlight.jpg" width="100" height="180">

<p>Click the light to change the lights.</p>


var image = ["Redlight.jpg", "RedAmber.jpg", "Greenlight.jpg", "Amber.jpg"];

function lightChange() {
    var image = document.getElementById('myImage');
    if (image.src.match("Greenlight.jpg")) {
        image.src = "Amber.jpg";
    } else {
        image.src = "Redlight.gif";

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download