webwizard-ai-nexus / script.js
mywebexpert's picture
Redesign my website
5a407e1 verified
Raw History Blame Contribute Delete
982 Bytes
// Shared JavaScript
document.addEventListener('DOMContentLoaded', () => {
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth'
});
}
});
});
// Dynamic navbar background on scroll
const navbar = document.querySelector('custom-navbar').shadowRoot.querySelector('nav');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.style.background = 'rgba(17, 24, 39, 0.95)';
navbar.style.boxShadow = '0 4px 6px -1px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.background = '';
navbar.style.boxShadow = '';
}
});
});