Javascript anchor link smooth scroll anchor ofset, load or click
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$('a[href*="#"]:not([href="#"])').click(function() { var target = $(this.hash); $('html,body').stop().animate({ scrollTop: target.offset().top - 100 }, 'linear'); }); if (location.hash){ var id = $(location.hash); } $(window).load(function() { if (location.hash){ $('html,body').animate({scrollTop: id.offset().top -100}, 'linear') }; }); |
Leave a Comment