(function ($) { $('a[href*="#"]') // .not('[href="#"]') .not('[href="#0"]') .click(function (event) { // On-page links if ( location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname ) { var target = $(this.hash); target = target.length ? target : $('[id=' + this.hash.slice(1) + ']'); if (target.length) { event.preventDefault(); $('html, body').animate({ scrollTop: target.offset().top }, 1000, function () { var $target = $(target); $target.focus(); if ($target.is(":focus")) { // Checking if the target was focused return false; } else { $target.attr('tabindex', '-1'); // Adding tabindex for elements not focusable $target.focus(); // Set focus again }; }); } } }); $(window).scroll(function () { var scrollTop = $(window).scrollTop(); if (scrollTop > $('.lies').offset().top) { if (!$('.top').hasClass('in')) { $('.top').addClass('in') } } if (scrollTop < $('.lies').offset().top) { if ($('.top').hasClass('in')) { $('.top').removeClass('in') } } }); })(jQuery);