-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (36 loc) Β· 1.38 KB
/
Copy pathscript.js
File metadata and controls
40 lines (36 loc) Β· 1.38 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
// Smooth Scrolling
document.querySelectorAll('nav ul li a').forEach(anchor => {
anchor.addEventListener('click', function (event) {
event.preventDefault();
const section = document.querySelector(this.getAttribute('href'));
section.scrollIntoView({ behavior: 'smooth' });
});
});
// Dark Mode Toggle
const darkModeBtn = document.createElement('button');
darkModeBtn.innerText = 'π Dark Mode';
darkModeBtn.style.position = 'fixed';
darkModeBtn.style.top = '10px';
darkModeBtn.style.right = '10px';
darkModeBtn.style.padding = '10px';
darkModeBtn.style.border = 'none';
darkModeBtn.style.cursor = 'pointer';
document.body.appendChild(darkModeBtn);
darkModeBtn.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
darkModeBtn.innerText = document.body.classList.contains('dark-mode') ? 'β Light Mode' : 'π Dark Mode';
});
// // Mobile Menu Toggle
// const nav = document.querySelector('nav ul');
// const toggleBtn = document.createElement('button');
// toggleBtn.innerText = 'β°';
// toggleBtn.style.position = 'fixed';
// toggleBtn.style.top = '10px';
// toggleBtn.style.left = '10px';
// toggleBtn.style.padding = '10px';
// toggleBtn.style.border = 'none';
// toggleBtn.style.cursor = 'pointer';
// document.body.appendChild(toggleBtn);
// toggleBtn.addEventListener('click', () => {
// nav.classList.toggle('show');
// });