Looks like there are multiple listeners for document ready. And your code is getting executed before other handler/handlers which sets the class active again. You can use e.stopImmediatePropagation()
to prevent that. Try this:
$(document).ready(function(e){
e.stopImmediatePropagation();
$('.nav li').removeClass('active');//or $('.active').removeClass('active');
});
Update:
You can also achieve this using setInterval()
:
setInterval(function(){
$('.active').removeClass('active');//remove class active
},1000);