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 ab5ca5f commit 9cbbd27
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,19 @@ document.addEventListener("DOMContentLoaded", function () {
let science_img = document.getElementById("science_img"); // acces a l'element HTML par son id
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 {
}
else {
scrollToTopBtn.style.display = "none";
}
});

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

0 comments on commit 9cbbd27

Please sign in to comment.