Posted By

LuckyShot on 12/04/09


Tagged

scroll jquery anchor


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

talbert


jQuery - Smooth anchor scrolling


 / Published in: JavaScript
 

Detects all anchor links in a page and makes them go to the place smoothly.

  1. var scrollWin = function (selector) {
  2. $('html, body').animate({
  3. scrollTop: $(selector).offset().top
  4. }, 2000);
  5. }
  6.  
  7. $("[href^=#]").click(function(e) {
  8. scrollWin ($(this).attr("href"));
  9. return false;
  10. });

Report this snippet  

You need to login to post a comment.