I'm trying to apply a smooth scroll animation on my webpage when the navbar links are clicked.
But the animate method isn't working and the links won't go to the next section when clicked thus leaving me stuck at the top most section when clicking the links.
I solved this by using the minified ver. of jQuery CDN instead of the slim minified.
Although the links go to their specified sections, the smooth scrolling effect still doesn't apply. They just skip to the next as though the duration property in my jQuery doesn't exist.
Am I doing something wrong here? I'm using Bootstrap 4 and I even tried including the jQuery UI CDN but it still doesn't work.
Also, I found this on my console output could this be the one that's causing the problem?
// Doesn't do the duration
$(".navbar a").click(function(e) {
e.preventDefault();
$("html, body").animate({
scrollTop: $(this.hash).offset().top
}, 1000);
});
<!-- The CDN's that I'm using -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>