Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
anaelle1531 authored Feb 1, 2025
1 parent c598db4 commit 063280b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,19 @@ document.addEventListener("DOMContentLoaded", function () {
science_img.setAttribute("src", "science1.jpg"); // modification d'un attribut de l'element HTML
}
});

document.addEventListener("DOMContentLoaded", function () {
let scrollToTopBtn = document.getElementById("scrollToTop");

window.addEventListener("scroll", function () {
if (window.scrollY > 300) {
scrollToTopBtn.style.display = "block";
} else {
scrollToTopBtn.style.display = "none";
}
});

scrollToTopBtn.addEventListener("click", function () {
window.scrollTo({ top: 0, behavior: "smooth" });
});
});

0 comments on commit 063280b

Please sign in to comment.