What is a good way to find the index of column by it's display text?
e.g.
<table>
<tr>
<td>ID</td>
<td>Name</td>
<td>Age</td>
</tr>
<tr>
...
</tr>
</table>
I would like to have something like
var nameIndex = getColIndex('Name'); // nameIndex = 1
Is there a quick / good way to do it? (Doesn't have to be jQuery, but would be nice)
Nameto be in a different column, or will it always be in1?Name? Or how about whitespace. Is there any chance that there could be leading or trailing whitespace, like line breaks?$.trim($(this).text()) == 'Name'Or a slightly more optimized version would be$.trim($.text([this])) == 'Name'