bootstrap 5 navbar collapse not working code example

Example 1: navbar toggle not working bootstrap 4

You need to put:-

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
Before all the other js files.

Then it will work.

Working example:- https://jsfiddle.net/mmqhw26j/

Note:- Take care that jQuery core-library/base-library need to be added first and then only any other jQuery file/library can be added

Example 2: collapse bootstrap navbar on click

$('.navbar-nav>li>a').on('click', function(){
    $('.navbar-collapse').collapse('hide');
});

Tags:

Misc Example