Skip to content

Instantly share code, notes, and snippets.

@alt-karate
Created August 28, 2021 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alt-karate/510ed9716dc186829820b8909f73efed to your computer and use it in GitHub Desktop.
Save alt-karate/510ed9716dc186829820b8909f73efed to your computer and use it in GitHub Desktop.
(参考サイト) https://yasuko213.jp/blog/?p=1112
// ページ内リンク時スムーズにスクロールします
$(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