Topics by Tech
Software Categories
Quick Links
You can detect anchor links using the selector, meaning you don't have to handle the alternate course (normal link) within the handler function.
In addition, delegating the 'a[href^=#]' means that any anchor links that are loaded later will also slide.
$('body').on('click', 'a[href^=#]', function (evt) { var $anchor = $(this).attr("href"); $('html,body').animate({ scrollTop: $($anchor).offset().top }, 1500, 'easeInOutExpo'); evt.preventDefault(); });
You can detect anchor links using the selector, meaning you don't have to handle the alternate course (normal link) within the handler function.
In addition, delegating the 'a[href^=#]' means that any anchor links that are loaded later will also slide.