I am using Twitter Bootstrap for a tabular interface. When I click on a tab, I am calling an function that hides and shows corresponding divs. This is my HTML Code:
<ul class="nav nav-tabs">
<li class="active" id="Chart1"><a href="#">Chart 1</a></li>
<li id="Chart2"><a href="#">Chart 2</a></li>
<li id="Chart3"><a href="#">Chart 3</a></li>
<li id="Chart4"><a href="#">Chart 4</a></li>
</ul>
Based on that, I am using the following jquery to show and hide content:
$(document).ready(function(){
$("#pie").hide();
$("#bar").hide();
$("#Chart2").click(function(){
$("#StateWise").hide();
$("#pie").show();
});
$("#Chart3").click(function(){
$("#StateWise").hide();
$("#pie").hide();
$("#bar").show();
});
});
How can I do that on click, the active class changes to that particular tab?
4
Answers
You can write like this:
Try this
Try
If you are using bootstrap 4 then you can do like this.
check the below reference
https://getbootstrap.com/docs/4.3/components/navs/#tabshow