//select the first TR element, then select its children (the TDs), //then filter them down to only the one that contains a certain string var theIndex = $('tr').first().children().filter(function () { return ($(this).text() == 'ID'); }).index();
When passing .filter() function, if you return true for the index, then it will be saved in the selection, and if you return false , then this index will be removed from the selection: http://api.jquery.com/filter
This will limit the search to the first row and give the index of the column with the specified search text (this code is used by ID ).
Note that .index() , when used as described above, will return the index of the current selection based on its sibling elements: http://api.jquery.com/index
source share