Created
March 22, 2013 06:08
-
-
Save spencejs/5219320 to your computer and use it in GitHub Desktop.
Scroll To Anchor Link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('a[href*=#]').bind('click', function(e) { | |
//e.preventDefault(); //prevent the "normal" behaviour which would be a "hard" jump | |
var target = $(this).attr("href"); //Get the target | |
// perform animated scrolling by getting top-position of target-element and set it as scroll target | |
$('html, body').stop().animate({ scrollTop: $(target).offset().top }, 600, function() { | |
//location.hash = target; //attach the hash (#jumptarget) to the pageurl | |
}); | |
//return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment