Skip to content

Commit 6281b98

Browse files
committed
cleaner burger js for 404
1 parent 944b639 commit 6281b98

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

site/static/js/burger.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
document.addEventListener('DOMContentLoaded', () => {
2+
// Get "navbar-burger" element
3+
const el = document.querySelector('.navbar-burger');
4+
5+
// Add a click event
6+
el.addEventListener('click', () => {
7+
8+
// Get the targets from the "data-target" attribute
9+
const target = el.dataset.target;
10+
const $target = document.getElementById(target);
11+
12+
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
13+
el.classList.toggle('is-active');
14+
$target.classList.toggle('is-active');
15+
});
16+
});

0 commit comments

Comments
 (0)