<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="myNavbar">
<div class="container">
<a class="navbar-brand" href="#Home"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon active"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#Home">Home
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#About">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#Contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
I have attempted the following code solution:
$('.navbar-nav>li>a').on('click', function(){
$('.navbar-collapse').collapse('hide');
});
However, when I implement this code, I encounter the issue depicted in the image here.
This code snippet was found on Stack Overflow, but I am unsure why it is not functioning correctly for me. Can anyone provide insight into what may be causing the problem?