I have been using Bootstrap to set up my first site and my navbar works perfectly well as a navigation bar. However, when the page is small enough for it to convert to a hamburger menu, on selection of a link it navigates me to the right place but the bar doesn't hide until I press the hamburger again.
I assume its because I'm not using the right JQuery or Bootstrap script (this is what most commonly seems to be the fix) but as far as I can tell with my very beginner knowledge its the most up-to-date version.
I have been looking at past answers and played around with the code but haven't been able to work out the issue.
Any thoughts?
HTML in head
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<!--Custom CSS-->
<link rel="stylesheet" href="style.css">
HTML for navbar
<!--navbar-->
<nav class="navbar sticky-top navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#jill">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#training">Training and Experience</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#sessions">Sessions and Fees</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact Me</a>
</li>
</ul>
<span class="navbar-text">
Here for you when you need it most
</span>
</div>
</nav>
HTML Scripts at bottom of page
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<!--smooth scroll-->
<script src="js/smooth-scroll.polyfills.min.js"></script>
<script>
$(document).on('click', 'a.nav-link', function(event) {
event.preventDefault();
console.log("CLICKED ANCHOR!");
$('html, body').animate({
scrollTop: $($.attr(this, 'href')).offset().top - $(".navbar.sticky-top").height()
}, 500);
});
</script>