This commit is contained in:
Aashish_Nepal
2024-12-11 16:39:59 +05:45
parent c7300bddd3
commit e22a2beaa6
3 changed files with 24 additions and 7 deletions

20
assets/js/header.js Normal file
View File

@ -0,0 +1,20 @@
document.querySelectorAll('.nav-link').forEach(function(link) {
link.addEventListener('click', function(e) {
const navbarCollapse = document.getElementById('navbarSupportedContent');
const bsCollapse = new bootstrap.Collapse(navbarCollapse, {
toggle: false
});
bsCollapse.hide();
const targetId = this.getAttribute('href').split('#')[1];
const targetElement = document.getElementById(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth'
});
}
});
});