The jqueryscrollTop method hides the top navigation bar based on the scrolling pixel display _ jquery

Source: Internet
Author: User
Use the scrollTop method of jquery to monitor the vertical scrolling pixels of the page and hide or display the navigation bar on the top of the page based on the pixels. The specific implementation code is as follows, if you are interested, refer to the following section to use jquery's scrollTop method to monitor vertical scrolling pixels on the page and hide or display the navigation bar at the top of the page based on pixels.
Effect preview URL: http://www.keleyi.com/keleyi/phtml/scrolloversee.htm

ScrollTop introduction:

Syntax
$ (Selector). scrollTop (offset)

Parameters
Offset
Description
Optional. Specifies the offset relative to the top of the scroll bar, in pixels.

Definition and usage
The scrollTop () method returns or sets the vertical position of the scroll bar that matches the element.
Scroll top offset refers to the offset of the scroll bar relative to its top.
If no parameter is set for this method, the offset relative to the top of the scroll bar in pixels is returned.

Tips and comments
Note: This method is valid for both visible and invisible elements.
Note: When used to obtain a value, this method returns only the scroll top offset of the First Matching Element.
Note: When used to set the value, this method sets the scroll top offset of all matching elements.

Complete code is provided and saved to an html file. You can use the following code to access the html file:

The Code is as follows:





Monitor scroll pixels, show or hide top navigation bar-ke leyi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.