How to scroll a control at the top of the screen

How to scroll (perfectly smooth scrolling) down so that the specified control is at the top of the screen? (i.e. how to bring the screen into the comments section so that the heading of the "comments" is at the top of the screen?)

+3
source share
3 answers

Like this:

$('html, body').animate({ scrollTop: $(something).offset().top });

Alternatively, you can use the ScrollToplugin .

+2
source

There is a ScrollTo plugin , which is quite popular. It is simple, simple:

$.scrollTo(...);
0
source

Source: https://habr.com/ru/post/1758954/


All Articles