May 2017
Intermediate to advanced
448 pages
10h 10m
English
Our switcher is behaving correctly, but we are not giving the user any feedback about which button is currently active. Our approach for handling this will be to apply the selected class to the button when it is clicked, and to remove this class from the other buttons. The selected class simply makes the button's text bold:
.selected { font-weight: bold; }
We could accomplish this class modification as we did previously by referring to each button by ID and applying or removing classes as necessary, but, instead, we'll explore a more elegant and scalable solution that exploits the context in which event handlers run.
When any event handler is triggered, the keyword this refers to the DOM element to which ...
Read now
Unlock full access