Created
August 28, 2016 15:43
-
-
Save akccakcctw/270f47fc5234f0b65dad41f83cbeb117 to your computer and use it in GitHub Desktop.
卷軸平滑捲動到頁面元素
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
//smooth scroll to #id | |
var $root = $('html, body'); | |
$('a.bookmark').click(function() { | |
var href = $.attr(this, 'href'); | |
$root.animate({ | |
scrollTop: $(href).offset().top | |
}, 500, function() { | |
window.location.hash = href; | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment