May 2017
Intermediate to advanced
448 pages
10h 10m
English
Suppose that we wanted to be able to hide our style switcher when it is not needed. One convenient way to hide page elements is to make them collapsible. We will allow one click on the label to hide the buttons, leaving the label alone. Another click on the label will restore the buttons. We need another class that will hide buttons:
.hidden { display: none; }
We could implement this feature by storing the current state of the buttons in a variable and checking its value each time the label is clicked to know whether to add or remove the hidden class on the buttons. However, jQuery provides an easy way for us to add or remove a class depending on whether that class is already present--the .toggleClass() ...
Read now
Unlock full access