Skip to content

Instantly share code, notes, and snippets.

@aoisensi
Created January 9, 2020 09:14
Show Gist options
  • Save aoisensi/2e283404a82a7906c42e6fbb2ef56270 to your computer and use it in GitHub Desktop.
Save aoisensi/2e283404a82a7906c42e6fbb2ef56270 to your computer and use it in GitHub Desktop.
document.addEventListener('DOMContentLoaded', () => {
const $navbarBurgers = <HTMLElement[]>Array.prototype.slice.call(
document.querySelectorAll('.navbar-burger'), 0
);
$navbarBurgers.forEach((el) => {
el.addEventListener('click', () => {
const target = el.dataset.target!;
const $target = document.getElementById(target);
el.classList.toggle('is-active');
$target?.classList.toggle('is-active');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment