Вопрос

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);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top