Jump to Categories

Vanilla JS

Add event listener to class items


const navdemos = Array.from(document.querySelectorAll('nav.demos > .demo'));

navdemos.forEach(link => link.addEventListener('click', (ev) => {
	ev.preventDefault();
	navigate(ev.target);
}));

Loop through classes


var dropdowns = document.getElementsByClassName('dropdown');
for (var i = 0; i < dropdowns.length; i++) {
dropdowns[i].classList.remove('show');
}

Class contains


var isCurrentDropdownShown = ulEl.classList.contains('show');

Refs