Home >Web Front-end >JS Tutorial >Example of scrollTop() method usage in jQuery_jquery
The example in this article describes the usage of the scrollTop() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:
This method returns or sets the vertical offset of the matching element's scroll bar.
Grammar structure 1:
When the scrollTop() method does not take parameters, it returns the offset of the matching element relative to the top of the scroll bar.
Example code:
Grammar structure 2:
When the scrollTop() method has parameters, set the top offset of the vertical scroll bar to this value.
Parameter list:
Example code:
I hope this article will be helpful to everyone’s jquery programming design.