Home > Web Front-end > JS Tutorial > body text

Example of scrollTop() method usage in jQuery_jquery

WBOY
Release: 2016-05-16 16:19:56
Original
1207 people have browsed it

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.

Copy code The code is as follows:
$(selector).scrollTop()

Example code:

Copy code The code is as follows:






scrollTop() function-Script Home













Grammar structure 2:

When the scrollTop() method has parameters, set the top offset of the vertical scroll bar to this value.

Copy code The code is as follows:
$(selector).scrollTop(val)

Parameter list:

参数 描述
val 设定垂直滚动条值

Example code:

Copy code The code is as follows:






scrollTop() function-Script Home













I hope this article will be helpful to everyone’s jquery programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!