3 ms·
An interesting use of 'classList' is that it makes it easy to use css-classes to indicate the state of a dom-element. Is the element selected or not? Well does
by galaxyLogic 6y ago
An interesting use of 'classList' is that it makes it easy to use css-classes to indicate the state of a dom-element. Is the element selected or not? Well does its classlist include the css-class 'selected'?
- atoav 6y agoThis is a good approach as it helps you solve a lot within CSS. Want to show the subpages of a selected menu point? Just use a css selector which changes their display state.
- edwinjm 6y agoDo not use classes to mark something as selected. People using screen readers won't know whether something is selected. Use aria attributes like aria-selected instead. https://www.w3.org/WAI/PF/aria/states_and_properties#aria-selected https://www.w3.org/WAI/PF/aria/states_and_properties#aria-se...