Use jqueryanimate to create a smooth scrolling effect (which can be at the top, bottom, or specified place) _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces how to use jqueryanimate to create a smooth scroll effect. The effect can be rolled to the top, to the bottom, or to a specified place on the page. The result is very smooth and comfortable, it is really convenient for a friend who needs to jump to the page by using the anchor. but to increase the effect of the webpage, you can use the animate in jquery to implement a rolling action, scroll slowly to the position you want to jump to, and it looks very tall.

Scroll to the top:

The code is as follows:

$ ('. Scroll_top'). click (function () {$ ('HTML, body'). animate ({scrollTop: '0px '}, 800 );});

Scroll to the specified position:

The code is as follows:

$ ('. Scroll_a '). click (function () {$ ('HTML, body '). animate ({scrollTop: $ ('. A '). offset (). top }, 800 );});


Complete instance source code reference:

The code is as follows:






Js smoothly scrolls to the top, bottom, and specified place

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.