Scroll to the id of the specified Element + the element is automatically loaded when it appears in the browser display area.

Source: Internet
Author: User

// Scroll to the id of the specified element, for example, $ ("# Exam82 ")

Function Jump (){

Var scroll_offset = $ ("# Exam82"). offset (); // obtain the offset of the div layer Exam82, which contains two values: top and left.

$ ("Body, html"). animate ({

ScrollTop: scroll_offset.top // make the scrollTop of the body equal to the top of Exam82, so that the scrolling is realized.

}, 2000); // 2000 controls the scroll speed}

// The element is automatically loaded when it appears in the browser display area.

Function autoloading (){

// Obtain the distance from $ ("# Exam86") to the top ($ ("# Exam86 "). offset (). top)-the height of the area displayed in the browser ($ (window ). height ())

Var totalheight = parseFloat ($ ("# Exam86"). offset (). top)-parseFloat ($ (window). height ());

// Obtain the vertical height from the scroll bar to the top:

Var guen = $ (document). scrollTop ();

If (parseInt (totalheight) <parseInt (guen )){

Alert ("loading... ");

}

}

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.