CSS property values are changed gradually so that you can create animation effects. Only numeric values can create animations (such as "margin:30px"). String values cannot create animations (such as "background-color:red").
Copy CodeThe code is as follows: $ (' #shang '). Click (function () {$ (' html,body '). Animate ({scrolltop: ' 0px '}, 800);});
The above code indicates that the scroll bar jumps to 0, and the page movement speed is 800. Practical examples of combining scrolltop:
Copy CodeThe code is as follows: JQuery (document). Ready (function ($) {$ (' #shang '). Click (function () {$ (' html,body '). Animate ({scrolltop: ' 0px '}, 800); }); $ (' #comt '). Click (function () {$ (' html,body '). Animate ({scrolltop:$ (' #comments '). Offset (). Top}, 800); }); $ (' #xia '). Click (function () {$ (' html,body '). Animate ({scrolltop:$ (' #footer '). Offset (). Top}, 800); }); });
Click the relevant ID to move to the specified location: Click on the element with ID Shang, go back to the top, click on the element with ID COMT, return to the location with ID comments, click on the element with ID Xia, and go back to the bottom;
How to realize ScrollTop method in jquery.animate by native JS
RadicalDecember 02, 2016 question
- concern4 Follow
- collection 0 favorites, 1k Browse
The problem is helpful, the content is complete, and I want to know the answer . 0 problems have no real value, lack of key content, no room for improvement
Can't find a good introduction to the Internet to achieve,
$(‘html, body‘).animate({ scrollTop: 800}, 1000)
How to control this scrolltop time?
- December 02, 2016 question
- Comments
- Invitation to answer
- Edit
-
xComments Support Section Markdown syntax:
**bold**
_italic_
[link](http://example.com)
> 引用
`code`
- 列表
。 At the same time, you will be notified by your @ user See all 3 answersthe answer is helpful to the person, has the reference value 0 The answer is no help, it's the wrong answer, irrelevantly replying .
What you need to do is not control the time, but control the step size, such as 800px,800ms, is 800ms within the 800px, if it is 1600px, then 800ms within the move 1600px
jquery animation effects animate and ScrollTop use instances together