How to know which bootstrap tab is active when I click a row in jquery datatable
How to know which bootstrap tab is active when I click a row in jquery datatable

Good day coders:
I have a jquery datatble which is up and running. In the same page, below the jquery datatable I have three bootsrap tabs. In the first tab I'm rendering an html information from an ajax request when the User click on any row in the datatable
$('#PlotDatatable').on('click', 'td', function ()
{
$.ajax
({
url: "/Erf/Details?id=" + $('#PlotDatatable').DataTable().cell(this, 0).data(),
type: 'GET',
cache: false,
success: function (data) {
$('#PartialZone').show();
$('#PartialZone').html(data);
}
});
});
The code works as a charm, The PartialZone above is a div t that is inside the first tab . But.....
The issue:
When the User choose a different tab, I obviously need to change the url of the ajax to send the relevant information . In this regard, I need to know which tab is actually activated so I can say : ..oh ....if tab whatever is activated ..then run this script .
Here is the mark up for the bootstap tab
- Progress On Site
- Defects
- Comments
- Contact
<div class="tab-pane fade" id="defects" role="tabpanel" aria-labelledby="defects-tab">
<div id="DefectsPartialZone" style="width:80% ; height:230px; display:none">
</div>
</div>
<div class="tab-pane fade" id="comments" role="tabpanel" aria-labelledby="comments-tab">
<div id="CommentsPartialZone" style="width:80% ; height:230px; display:none">
</div>
</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
<div id="ContactPartialZone" style="width:80% ; height:230px; display:none">
</div>
</div>
This question has an accepted answers - jump to answer
Answers
The active tab should have the
.active
class so you could do something like:Hi Bur.
Many thanks for your assistance It works ...have a nice day further my man !!!
Happy to help. Alternatively you can do:
It's slightly more readable so might be better to use this instead of my previous suggestion.