Created
September 17, 2019 18:02
-
-
Save Giagnus64/e8fff81659485d815417909af2af61d1 to your computer and use it in GitHub Desktop.
Other Event Listener function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const colorBtnSim = document.querySelector(".simulate-color"); | |
| const divToChange = colorBtn.parentElement; | |
| colorBtnSim.addEventListener('click', colorBtnSimClicked); | |
| function colorBtnSimClicked(event){ | |
| const colors = ["skyblue", "green", "orange", "yellow"]; | |
| event.target.parentElement.style.backgroundColor = colors[Math.floor(Math.random()*colors.length)]; | |
| } | |
| //original color button event listener | |
| const colorBtn = document.querySelector(".color-button"); | |
| colorBtn.addEventListener('click', colorBtnClicked); | |
| // original color button callback | |
| function colorBtnClicked(event){ | |
| const colors = ["skyblue", "green", "orange", "yellow"]; | |
| event.target.parentElement.style.backgroundColor = colors[Math.floor(Math.random()*colors.length)]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment