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

jquery scrollTop method shows and hides the top navigation bar according to the scroll pixel_jquery

WBOY
Release: 2016-05-16 17:33:10
Original
1939 people have browsed it

This article uses jquery's scrollTop method to monitor the vertical scrolling pixels of the page, and hide or display the top navigation bar based on the pixels.
Effect preview URL: http://www.keleyi.com/keleyi/phtml/scrolloversee.htm

Introduction to scrollTop:

Syntax
$(selector).scrollTop(offset)

Parameters
offset
Description
Optional. Specifies the offset, in pixels, from the top of the scroll bar.

Definition and Usage
scrollTop() method returns or sets the vertical position of the scroll bar of the matching element.
scroll top offset refers to the offset of the scroll bar relative to its top.
If this method sets no parameters, returns the offset in pixels from the top of the scroll bar.

Tips and Notes
Note: This method works for both visible and invisible elements.
Note: When used to get a value, this method only returns the scroll top offset of the first matching element.
Note: When used to set a value, this method sets the scroll top offset of all matching elements.

Attach the complete code, save it to an html file, open it to experience the effect:

Copy the code The code is as follows:




监视滚动像素,显示或隐藏顶部导航条-柯乐义





请滚动鼠标使页面向下

www.keleyi.com

欢迎

hi

柯乐义

keleyi.com

keleyi

keleyi.com

柯乐义

柯乐义 监视下滚像素

A

jquery


keleyi.com

完整代码




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