Search code examples
javascriptanimationfrontendsmoothingsmooth-scrolling

why smooth scroll JS is not working in my web


I need help, I ve been fighting with this whole day, but cant really find a problem why this is not working.

https://jsfiddle.net/bk51xgrq/13/

$(function () {
  $('a[href*="#"]').click(function () {
     var $target = $(this.hash);
     $target = $target.length ? $target : $('html');
     var targetOffset = $target.offset().top;
     $('html,body').animate({scrollTop: targetOffset}, {duration: 8600, easing: 'easeInBounce'});
  });
});

Solution

  • You are using jQuery but you haven't included it in your project. You can link to it using the CDN in your html document

     <!--jQuery -->
       <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>