how can you get a row by the index?
var rows = $('tr', tbl);
rows.index(0).addClass('my_class');
Alternatively, you can select rows from the list index by using df. loc[df. index[]] method. loc[] method is used to select the rows by labels.
To select the rows, the syntax is df. loc[start:stop:step] ; where start is the name of the first-row label to take, stop is the name of the last row label to take, and step as the number of indices to advance after each extraction; for example, you can use it to select alternate rows.
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');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With