I have the following menu by bootstrap
HTML
$(".ul li").on("click", function() {
$(this).siblings().removeClass('active');
$(this).addClass("active");
});
This is the solution that worked for me. I declared this to become active and remove the active class and also adding the .siblings() method that allows you to search for the siblings of the li elements in the document.