forked from alphacodess/alphacodess.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (29 loc) · 1.12 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
document.addEventListener('DOMContentLoaded', function () {
// Get all "navbar-burger" elements
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(function ($el) {
$el.addEventListener('click', function () {
// Get the target from the "data-target" attribute
var target = $el.dataset.target;
var $target = document.getElementById(target);
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
$el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});
document.querySelectorAll('.navbar-link').forEach(function(navbarLink){
navbarLink.addEventListener('click', function(){
navbarLink.nextElementSibling.classList.toggle('is-hidden-mobile');
})
});
$('.navbar-item').click(function (e) {
var li = $(this).closest('li');
if (li.hasClass('active')) {
li.css('background-color', '#1A1C23'); //or inherit
}
});