const gotopBtn = document.getElementById("gotop-btn");
// document.body:修改成目标元素的DOM对象
gotopBtn.addEventListener("click", () => document.body.scrollIntoView({ behavior: "smooth" }));
// gotopBtn.addEventListener("click", () => document.getElementById("gotop-btns").scrollIntoView({ behavior: "smooth" }));
JavaScript回到顶部
最新推荐文章于 2022-11-01 19:41:37 发布