Return to Snippet

Revision: 21526
at December 15, 2009 09:57 by adambundy


Initial Code
$('a[href*=#]').click(function() {
 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
 && location.hostname == this.hostname) {
   var $target = $(this.hash);
   $target = $target.length && $target
   || $('[name=' + this.hash.slice(1) +']');
   if ($target.length) {
  var targetOffset = $target.offset().top;
  $('html,body')
  .animate({scrollTop: targetOffset}, 900);
    return false;
   }
 }
  });

Initial URL


Initial Description


Initial Title
jQuery smooth scroll to an anchor

Initial Tags


Initial Language
jQuery