$(function () { $("a[href^='#']").click(function () { var speed = 500 var href = $(this).attr('href') var target = $(href == '#' || href == '' ? 'html' : href) var position = target.offset().top $('html, body').animate({ scrollTop: position }, speed, 'swing') return false }) //TOPへ戻るボタン設定 var topBtn = $('#page-top') topBtn.hide() //スクロールが100に達したらボタン表示 $(window).scroll(function () { if ($(this).scrollTop() > 100) { topBtn.fadeIn() } else { topBtn.fadeOut() } }) //スクロールしてトップ topBtn.click(function () { $('body,html').animate( { scrollTop: 0, }, 500 ) return false }) //板付き設定 $('#close').click(function () { $('#plate').fadeOut('5000') }) $(window).scroll(function () { if ($(this).scrollTop() == 0 && window.innerWidth >= 768) { $('#plate').fadeIn('5000') } }) $(window).scroll(function () { if ($(this).scrollTop() > 800) { $('#plate').addClass('on') } else { $('#plate').removeClass('on') } }) $('#close02').click(function () { $('#plate02').fadeOut('5000') }) $(window).scroll(function () { if ($(this).scrollTop() == 0 && window.innerWidth >= 768) { $('#plate02').fadeIn('5000') } }) $(window).scroll(function () { if ($(this).scrollTop() > 800) { $('#plate02').addClass('on') } else { $('#plate02').removeClass('on') } }) var header = $('#header1') var sticky = header.offset().top $(window).scroll(function () { if ($(this).scrollTop() > sticky) { header.addClass('sticky') } else { header.removeClass('sticky') } }) })