In this article, we will discuss how to run the code when users scroll the content using jQuery. To run the code on scrolling the content, the scroll() method is used. The scroll() method is used to run the code when the user scrolls in the specified element.
Parameter: This method accepts single parameters function which is optional. It is used to specify the function to run when the scroll event is triggered.
Approach: In the below example, we have created a div element that contains the content of the element and we have used some CSS styles on the div element. We have added an overflow-y property to scroll to make content scrollable. When the user scrolls the div content, the jQuery scroll() method is called and this method contains css() method that applies some CSS styles on the div element.
Please Login to comment...