Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript (preferably Jquery) that will mimic behavior of hashtags [duplicate]

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?

like image 425
Spencer Avatar asked Jan 24 '12 16:01

Spencer


1 Answers

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);
like image 78
zzzzBov Avatar answered Nov 05 '22 13:11

zzzzBov