Javascript (preferably Jquery) that will mimic behavior of hashtags [duplicate]
-
13-11-2019 - |
Вопрос
Possible Duplicate:
jQuery scroll To Element
Basically, I want my user to be instantly scroll down to a specific anchor tag just like they do with a hashtag. However, I can't use a hashtag and therefore want to scroll them down using javascript (preferably jquery).
Any thoughts on how to do this?
Решение
This will jump instantly to the element matched by $(selector)
:
$(document).scrollTop($(selector).offset().top);
If you want a fluid animation:
$(document.body).animate({'scrollTop': $(selector).offset().top}, duration);
Не связан с StackOverflow