Created
June 14, 2019 09:35
-
-
Save k-ish/6859da0e666eed2fa350a6ad629e334b 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
// スムーズスクロール | |
$('a[href^=#]').click(function() { | |
var speed = 400; // ミリ秒 | |
var href= $(this).attr("href"); | |
var target = $(href == "#" || href == "" ? 'html' : href); | |
var position = target.offset().top; | |
$('body,html').animate({scrollTop:position}, speed, 'swing'); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment