Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ h1 {
margin: 25px auto;
transition: background 500ms;
}

3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<meta charset="UTF-8">
<title>jQuery Traffic Light</title>

<link rel="stylesheet" href="css/style.css" media="screen" type="text/css" />
</head>

Expand All @@ -23,5 +22,7 @@ <h1 id="goButton" class="button">Go</h1>
<div id="goLight" class="bulb"></div>
</div>

<script src="js/jquery-2.1.4.js"></script>
<script src="js/light.js"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions js/light.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$(document).ready(function(){

$("#stopButton").click(goRed);
$("#goButton").click(goGreen);
$("#slowButton").click(goYellow);

//functions to change colors below
function goRed() {
clearLight();
$("#stopLight").css("backgroundColor", "red");
}

function goGreen() {
clearLight();
$("#goLight").css("backgroundColor", "green");
}

function goYellow() {
clearLight();
$("#slowLight").css("backgroundColor", "yellow");
}


function clearLight() {
$("#stopLight").css("backgroundColor", "black");
$("#goLight").css("backgroundColor", "black");
$("#slowLight").css("backgroundColor", "black");

}


});