SAEWEB2.2/ci/assets/bouton.js

25 lines
743 B
JavaScript
Raw Normal View History

2024-05-30 10:05:37 +02:00
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
// Afficher ou masquer le bouton de scroll en fonction de la position dans la page
document.addEventListener('scroll', function () {
const scrollTopBtn = document.getElementById('scrollTopBtn');
if (window.scrollY > 200) {
scrollTopBtn.style.display = 'block';
} else {
scrollTopBtn.style.display = 'none';
}
});
// Menu burger
document.addEventListener('DOMContentLoaded', function () {
const burgerMenu = document.querySelector('.burger-menu');
const navLinks = document.querySelector('.nav-links');
burgerMenu.addEventListener('click', function () {
navLinks.classList.toggle('show');
});
});