SAE_S1.05_S1.06/js/script.js

29 lines
789 B
JavaScript
Raw Normal View History

// Menu burger
document.addEventListener('DOMContentLoaded', function () {
2024-01-12 21:09:55 +01:00
const burgerMenu = document.querySelector('.burger-menu');
const navLinks = document.querySelector('.nav-links');
2024-01-12 21:09:55 +01:00
burgerMenu.addEventListener('click', function () {
navLinks.classList.toggle('show');
});
2024-01-12 21:09:55 +01:00
});
2024-01-13 00:52:08 +01:00
// Scroll jusqu'en au de la page
2024-01-13 00:52:08 +01:00
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
// Afficher ou masquer le bouton de scroll en fonction de la position dans la page
2024-01-13 00:52:08 +01:00
document.addEventListener('scroll', function () {
const scrollTopBtn = document.getElementById('scrollTopBtn');
if (window.scrollY > 200) {
scrollTopBtn.style.display = 'block';
} else {
scrollTopBtn.style.display = 'none';
}
});