-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
30 lines (22 loc) · 978 Bytes
/
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
$(document).ready(function() {
// Navigation Menu
const menuButton = document.querySelector( '.js-open-menu' );
const menuButtonIcon = menuButton.querySelector( 'i' );
const navMenu = document.querySelector( '.menu' );
const isVisibleClass = 'is-visible';
menuButton.addEventListener( 'click', function() {
// Toggle button color state
menuButton.classList.toggle( 'button--active' );
// Toggle button icon
if ( menuButtonIcon.classList.contains( 'ph-list' ) ) {
menuButtonIcon.classList.remove( 'ph-list' );
menuButtonIcon.classList.add( 'ph-x' );
}
else if ( menuButtonIcon.classList.contains ( 'ph-x' ) ) {
menuButtonIcon.classList.remove( 'ph-x' );
menuButtonIcon.classList.add( 'ph-list' );
}
// Toggle menu visibility
navMenu.classList.toggle( isVisibleClass );
});
});