Scripts for ‘scrolling to an id’ (such as jQuery.scrollTo) have unnecessary customization options and do not handle all page links, pointing to anchors, on their own. (or is it just me?)
Solution
jQuery('a[href*=\"#\"]').on('click', function(e) { e.preventDefault() jQuery('html, body').animate( { scrollTop: jQuery(jQuery(this).attr('href')).offset().top, } ,500 ,'linear' ) });
- Credits: https://www.taniarascia.com/smooth-scroll-to-id-with-jquery/
- Demo: https://codepen.io/taniarascia/pen/MJEXZj
Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.