-
Notifications
You must be signed in to change notification settings - Fork 0
/
myscript.js
40 lines (36 loc) · 1.14 KB
/
myscript.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
39
40
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight){
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + "px";
}
});
}
var toggledisplay = document.querySelector('#disnav');
var fixed = document.querySelector('.fixed');
//var navbar = document.querySelector('#nav');
var content = document.querySelector('html');
// add a click event listener to the div
toggledisplay.addEventListener('click', function() {
// specify the action to take when the div is clicked
if(fixed.style.left == "0px"){
fixed.style.left = "-100%";
content.style.overflowY = "visible";
}
else{
fixed.style.left = "0px";
content.style.overflowY = "hidden";
}
});
var navlinks = document.querySelectorAll('.menu > ul > li');
for(i = 0; i < navlinks.length; i++){
navlinks[i].addEventListener("click", function(){
fixed.style.left = "-100%";
content.style.overflowY = "visible";
});
}