Javascript » Event Context
👉 User Story:
As a user
Given page with some red buttons
When clicking on a button
Then the button should become green
And when clicking again
THen the button should go back to red
You can try things out directly on this pen:
https://codepen.io/marcopeg/pen/QWLVLMB
NOTE: In this exercise you need to play with HTML, CSS and Javascript!
✅ Proposed Solution:
Don't run this unless you gave a very good effort to solve it yourself!
🤓 Resources:
- MDN: event context properties
- MDN: web events list
- MDN: persist data into elements
- MDN: ternary operator conditional
- MDN: classList
- MDN: arrow functions
- MDN: querySelectorAll
- MDN: forEach