-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (20 loc) · 761 Bytes
/
Copy pathindex.js
File metadata and controls
21 lines (20 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Select the nav element
const nav = document.querySelector('nav');
// Add an event listener for scroll events
window.addEventListener('scroll', () => {
// Check if the scroll position is greater than 120 pixels
if (window.scrollY > 120) {
// Change the background color of the nav element
nav.style.opacity="0.5";
} else {
// Reset background color when scroll position is less than or equal to 120 pixels
nav.style.backgroundColor = 'black';
nav.style.color = 'white'; // Optional: reset text color
}
});
function closesidebar(){
document.getElementById("sidebar").style.display="none";
}
function opensidebar(){
document.getElementById("sidebar").style.display="flex";
}