Sometimes, we want to listen for scroll event for iPhone or iPad with JavaScript.
In this article, we’ll look at how to listen for scroll event for iPhone or iPad with JavaScript.
How to listen for scroll event for iPhone or iPad with JavaScript?
To listen for scroll event for iPhone or iPad with JavaScript, we can listen to the scroll event.
For instance, we write
window.addEventListener("scroll", () => {
console.log("Scrolled");
});
window.onscroll = () => {
console.log("Scrolled");
};
to call window.addEventListener
to add the scroll event listener.
The callback runs when we scroll on our iPhone or iPad.
Likewise, we set window.onscroll
to a function that runs when we scroll to add a scroll event listener.
Conclusion
To listen for scroll event for iPhone or iPad with JavaScript, we can listen to the scroll event.