Improve the solution
This commit is contained in:
parent
ba764541e2
commit
2ac097d1ac
4
index.js
4
index.js
@ -9,8 +9,6 @@
|
|||||||
const slowLight = document.querySelector('#slowLight');
|
const slowLight = document.querySelector('#slowLight');
|
||||||
const goLight = document.querySelector('#goLight');
|
const goLight = document.querySelector('#goLight');
|
||||||
|
|
||||||
const controls = document.querySelector('#controls');
|
|
||||||
|
|
||||||
// part 1
|
// part 1
|
||||||
stopButton.addEventListener('click', () => {
|
stopButton.addEventListener('click', () => {
|
||||||
const color = stopLight.style.backgroundColor === 'red' ? '' : 'red';
|
const color = stopLight.style.backgroundColor === 'red' ? '' : 'red';
|
||||||
@ -48,6 +46,8 @@
|
|||||||
goButton.addEventListener('mouseleave', handleMouseLeave);
|
goButton.addEventListener('mouseleave', handleMouseLeave);
|
||||||
|
|
||||||
// bonus
|
// bonus
|
||||||
|
const controls = document.querySelector('#controls');
|
||||||
|
|
||||||
controls.addEventListener('click', (event) => {
|
controls.addEventListener('click', (event) => {
|
||||||
if (event.target === controls) {
|
if (event.target === controls) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user