Smooth scrolling for internal links


/ Published in: jQuery
Save to your folder(s)

Smooth scrolling for internal links


Copy this code and paste it in your HTML
  1. $('a[href^="#"]').bind('click.smoothscroll',function (e) {
  2. e.preventDefault();
  3.  
  4. var anchor = this.hash,
  5. $target = $(target);
  6.  
  7. $('html, body').stop().animate({
  8. 'scrollTop': $target.offset().top
  9. }, 500, 'swing', function () {
  10. window.location.hash = anchor;
  11. });
  12.  
  13. });

URL: http://imakewebthings.github.com/jquery-waypoints/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.