17 lines
700 B
JavaScript
17 lines
700 B
JavaScript
// From https://bulma.io/documentation/components/navbar/
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
|
if ($navbarBurgers.length > 0) {
|
|
$navbarBurgers.forEach(el => {
|
|
el.addEventListener('click', () => {
|
|
// Get the target from the "data-target" attribute
|
|
const target = el.dataset.target;
|
|
const $target = document.getElementById(target);
|
|
|
|
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
|
el.classList.toggle('is-active');
|
|
$target.classList.toggle('is-active');
|
|
});
|
|
});
|
|
}
|
|
});
|