how can you get a row by the index?
var rows = $(\'tr\', tbl);
rows.index(0).addClass(\'my_class\');
Use .eq()
.
var rows = $('tr', tbl);
rows.eq(0).addClass('my_class');
...or for your simple case, .first()
:
rows.first().addClass('my_class');
Using either the eq() function:
rows.eq(0).addClass('my_class');
Or the :eq() selector:
$('tr:eq(0)', tbl).addClass('my_class');
For the first element (index 0) the answer provided to your earlier question should be fine.
For any nth element use eq selector
e.g:
var rows = $('tr:eq(8)', tbl);