Return to Snippet

Revision: 54090
at November 26, 2012 23:52 by mortu


Updated Code
$(document).ready(function(){
	$('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
	            }, 1000);
	        	return false;
	        }
	    }
	});
});

Revision: 54089
at December 9, 2011 21:07 by mortu


Initial Code
$(document).ready(function(){
  $('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
               }, 1000);
                      return false;
                }
         }
  });
});

Initial URL


Initial Description
scrollTo jQuery

Initial Title
scrollTo jQuery

Initial Tags
plugin

Initial Language
jQuery