(selector)
| 1 | // The word "toggle" means turn on/off. |
| 2 | function toggleButton(selector) { |
| 3 | const button = document.querySelector(selector); |
| 4 | if (!button.classList.contains('is-toggled')) { |
| 5 | |
| 6 | // Before turning this button ON, check if there's |
| 7 | // already a button that's turned ON and turn it OFF. |
| 8 | turnOffPreviousButton(); |
| 9 | |
| 10 | button.classList.add('is-toggled'); |
| 11 | } else { |
| 12 | button.classList.remove('is-toggled'); |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | function turnOffPreviousButton() { |
| 17 | const previousButton = document.querySelector('.is-toggled'); |
nothing calls this directly
no test coverage detected