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
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<title>Stoplight Exercise</title>
<script defer src="index.js"></script>
<link rel="stylesheet" href="index.css">
<script
src="https://code.jquery.com/jquery-3.1.1.slim.min.js"
integrity="sha256-/SIrNqv8h6QGKDuNoLGA4iret+kyesCkHGzVUUV0shc="
crossorigin="anonymous"></script>
</head>
<body>
<div id="controls">
Expand Down
38 changes: 34 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
(function() {
'use strict';
'use strict';
$(function() {

// YOUR CODE HERE
})();
var buttonsss = document.getElementById('controls')
var theBulbs = document.getElementsByClassName('bulb')
// console.log(theBulbs.);

buttonsss.addEventListener("click", function(ev) {
console.log(ev.target);
$('#stopLight').css({
backgroundColor: '#111'
})
$('#slowLight').css({
backgroundColor: '#111'
})
$('#goLight').css({
backgroundColor: '#111'
})
switch (ev.target.textContent) {
case 'Stop':
return document.getElementById('stopLight').style.backgroundColor = 'red';
break;
case 'Slow':
return document.getElementById('slowLight').style.backgroundColor = 'orange';
break;
case 'Go':
return document.getElementById('goLight').style.backgroundColor = 'green';
break;
default:
theBulbs.style.backgroundColor = '#111'
}

})

});