Created
August 28, 2021 05:32
-
-
Save alt-karate/510ed9716dc186829820b8909f73efed 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
// ページ内リンク時スムーズにスクロールします | |
$(function () { | |
// #で始まるアンカーをクリックした場合に処理 | |
$('a[href^="#"]'+ 'a,area').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