I have a bootstrap button group with few buttons each of them with their a tag that links to a new page. I've added the jquery code for retaining the active state when a button is clicked. The buttons stay active on clicking only if there is no #href. When there is a link and the new page is loaded, the active state is lost. Can someone please help ? I am so lost!
Here is the snippet - html:
<div class="btn-group">
<a class="btn btn-custom">Home </a>
<a class="btn btn-custom" href="/link1"> About us </a>
<a class="btn btn-custom" href="/link2"> Contact us </a>
</div>
Jquery:
$(".btn-group > .btn").click(function(){
$(this).addClass("active").siblings().removeClass("active");
});