100-project-100-days-website/100_projects/20-scroll-to-top-button/main.js
2023-03-13 17:14:17 +03:00
Ask

12 lines
268 B
JavaScript

{0a3a0d150f316d646147fa17aacf4e78dcdc46a8 true 268 main.js 0xc002a84fc0}

let span = document.querySelector(".up");
window.onscroll = function () {
this.scrollY >= 1000 ? span.classList.add("show") : span.classList.remove("show");
};
span.onclick = function () {
window.scrollTo({
top: 0,
behavior: "smooth",
});
};