bootstrap 3 navbar collapse button not working

bootstrap 3 navbar collapse button not working

I did some modification in navbar but now the toggle button is not responding on click.
Below is my code. Where I am wrong ??



Solution 1:

You need to change in this markup

 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar collapse">

change the

data-target=".navbar collapse"



Reason : The value of data-target is a any class name of the associated nav div. In this case it is

<div class="collapse navbar-collapse">  <-- Look at here
     <ul class="nav navbar-nav navbar-right">

Js Fiddle Demo

Solution 2:

I had a similar problem. Looked over the html several times and was sure it was correct. Then I started playing around with the order of jquery and bootstrap javascript.

Originally I had bootstrap.min.js loading BEFORE jquery.min.js. In this state, the menu would not expand when clicking on the menu icon.

Then I changed the order so that bootstrap.min.js came after jquery.min.js, and this solved the problem. I don’t know enough about javascript to explain why this caused the problem (or fixed it), but that is what worked for me.

Additional info:

Both scripts are located at the bottom of the page, just before the tag.
Both scripts are hosted on CDNs, not locally hosted.

If you’re pretty sure your code is correct, give this a try.

Solution 3:

In <body> you should have two <script> tags:

<script src=""></script>
<script src="js/bootstrap.js"></script>

The first one will load jQuery from the CDN, and second one will load Bootstrap’s Javascript from a local directory (in this case it’s a directory called js).

Solution 4:

Well i had the same problem what when i added the following code within the tag
my problem fixed :

       <meta name="viewport" content="width=device-width , initial-scale=1" />

I hope this can help you guys!

Solution 5:

It happened with me, I used jquery.min.js file that downloaded from bootstrap site
it is not working, I tried same page with other jquery.min.js file it worked fine so if you face this problem try to reference other jquery.min.js file in your page and try again

Solution 6:

Just my 2 cents, had:

<script src=""></script>

at the end of body, wasn’t working, had to add crossorigin="anonymous" and now it’s working, Bootstrap version 3.3.6. …