$(function () { $('.navToggle').click(function () { $(this).toggleClass('active'); if ($(this).hasClass('active')) { $('.l-header_nav').addClass('active'); $('.l-header_contact').addClass('active'); } else { $('.l-header_nav').removeClass('active'); $('.l-header_contact').removeClass('active'); } }); $('.l-header_nav a').click(function () { $('.navToggle').trigger("click"); }); }); $(function(){ $('a[href^="#"]').on("click", function() { var speed = 600; var header_height = $("header").height(); var href= $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top - header_height; $('body,html').animate({scrollTop:position}, speed, 'swing'); return false; }); }); $(function(){ $(window).on('scroll', function(){ if ($(window).scrollTop() > 300) { $('.right_triangle').fadeOut(400); } else { $('.right_triangle').fadeIn(400); } }); }); $(function(){ var pagetop = $('.l-btn__pagetop'); // ボタン非表示 pagetop.hide(); // 100px スクロールしたらボタン表示 $(window).scroll(function () { if ($(this).scrollTop() > 100) { pagetop.fadeIn(); } else { pagetop.fadeOut(); } }); pagetop.click(function () { $('body, html').animate({ scrollTop: 0 }, 500); return false; }); });