document
document.queryselector
//HTML
<span class="memo" data-speed="1">
<i class="fas fa-xx"></i>
</span>
//JS
const memo = document.querySelector('.memo');
memo.style.transform = `translateY(${scrollPositionY * moonMoveSpeed}px)`;
//JS 多重選取就要用foreach更變
let boxes = document.querySelectorAll(".box");
function checkBoxes() {
boxes.forEach((box) => {
let boxTop = box.getBoundingClientRect().top;
if (boxTop < triggerBottom) {
box.classList.add("show");
} else {
box.classList.remove("show");
}
});
}
Last updated