-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (38 loc) · 1.33 KB
/
script.js
File metadata and controls
45 lines (38 loc) · 1.33 KB
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
41
42
43
44
45
var menuButton = document.getElementById('main-nav-menu-btn');
var dropdownMenu = document.getElementById('main-nav-dropdown-menu');
var menuExitButton = document.getElementById('dropdown-menu-btn');
var bodyElement = document.getElementById('body');
menuButton.addEventListener('click', function() {
dropdownMenu.style.display = 'block';
bodyElement.style.overflow = 'hidden';
});
menuExitButton.addEventListener('click', function() {
dropdownMenu.style.display = 'none';
bodyElement.style.overflow = 'scroll';
});
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.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
var mybutton = document.getElementById("backToTop");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}