JSFiddle - React, Tailwind, and code Playground
HTML
<table id="my_table">
<thead>
<th>Supp</th>
<th>Report</th>
<th>Other</th>
</thead>
</table>
JavaScript
//Loop thru the headers and get the Supp elem
var suppCol = $("#my_table th").each(function() {
alert($(this).html() == "Supp"); //Sanity check
if ($(this).html() == "Supp") {
return $(this);
}
});
//Loop thru the headers and get the Report elem
var reportCol = $("#my_table th").each(function() {
alert($(this).html() == "Report"); //Sanity check
if ($(this).html() == "Report") {
return $(this);
}
});
alert(suppCol.html() + ", " + reportCol.html()); //Sanity check
suppCol = $("#my_table th").index(suppCol);
reportCol = $("#my_table th").index(reportCol);
alert(suppCol + ", " + reportCol); //Should have 0 and 1, right??