1
votes

I just can't remove class 'active' from navbar. I tried this :

$(document).ready(function(e){ e.stopImmediatePropagation(); $('.nav li').removeClass('active');//or $('.active').removeClass('active'); });

Also tried this:

setInterval(function(){ $('.active').removeClass('active');//remove class active },1000);

EDIT:

This actually works but doesn't work for me:

jQuery(document).ready(function($){$('.nav li').removeClass('active');});}

I have to mention that I have another navigation in dropdown which probably trigger 'active' class from Twitter Bootstrap Nav Tabs. So I think I can apply this function only on class given to main navigation? So I tried this:

<script>jQuery(document).ready(function($){$('.no-active li').removeClass('active');});} </script>

HTML:

<ul id="menu-menu-1" class="nav navbar-nav no-active">

But my main navigation still gets class 'active' whenever moving across:

<ul class="nav nav-tabs">
1
Why don't you just remove it in the html? You would add this in your CMS application in the menu functions. - Christina
No html here. 'active' class comes from bootstrap inner functionallity. - worldwildwebdev

1 Answers

1
votes

Update

If you're using the Bootstrap nav tabs then this works for me to remove active from the currently active list element

$(".nav-tabs > li.active").removeClass("active")

I don't think just selecting .nav works because it will select all the elements with 'nav' class (including your main navigation). I'm still not sure I 100% understand your problem, I hope this helps though.


I just tried this on the Bootstrap website (do you have a Bootstrap navbar?) using Chrome dev tools and

$('.nav li').removeClass("active")

works fine for me. Could you give a sample of your HTML?