Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select rows in a table except the table header rows

Tags:

How to select rows in a html table except the table header rows using jquery?

 <table id="mytable">         <thead>             <tr>                 <th>                     Foo                 </th>                 <td>                     Lorem                 </td>                 <td>                     Ipsum                 </td>             </tr>         </thead>         <tr>             <th>                 Bar             </th>             <td>                 Dolor             </td>             <td>                 Sit             </td>         </tr>         <tr>             <th>                 Baz             </th>             <td>                 Amet             </td>             <td>                 Consectetuer             </td>         </tr>     </table> 
like image 289
TrustyCoder Avatar asked Jul 28 '10 07:07

TrustyCoder


People also ask

What is a table header row?

A table header row is the top row of a table that acts as a title for the type of information they will find in each column.

How do I change the header row in a table?

To change the table header row, select the new row you would like to set as the table header, right-click on the row header, and select "Set row as table header" from the dropdown.

What is a table with headers?

A table header is a row at the top of a table used to label each column. For example, in the below table there are three columns with a "Name," "Date of Birth," and "Phone" header. Example of a table header in HTML. Header row in a Microsoft Excel table. Header row in Microsoft Word.

Which tag allows row heading in table?

<tr>: The Table Row element. The <tr> HTML element defines a row of cells in a table. The row's cells can then be established using a mix of <td> (data cell) and <th> (header cell) elements.


2 Answers

$('tr').not('thead tr').addClass('selected') 
like image 101
Reigel Avatar answered Sep 23 '22 16:09

Reigel


You should wrap the rows in a <tbody> element (some browsers will do this anyway!), then select the children of that tbody:

$('#mytable > tbody > tr'); 
like image 28
Andy E Avatar answered Sep 20 '22 16:09

Andy E