Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to groups table rows in html to manipulate them with jquery

Tags:

html

jquery

dom

I have an html table with many rows. I'm currently grouping several rows inside a div (I know this is ugly) and then show or hide the divs to show or hide the rows inside it. Is there a standard way to do this. Something like rowgroup or multiple tbody instead of this ugly div grouping?

like image 626
Ricardo Marimon Avatar asked Mar 18 '10 13:03

Ricardo Marimon


People also ask

How to group rows in html table?

table-row-group (In HTML: TBODY) Specifies that an element groups one or more rows. table-header-group (In HTML: THEAD) Like 'table-row-group', but for visual formatting, the row group is always displayed before all other rows and row groups and after any top captions.

Which tag is used to group the rows of the 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.

How do you edit a row in a table using Javascript?

In first function that is edit_row() function is used to edit rows. In this function we get row id in 'no' variable and then we hide and edit button and display the save button then we get all the data of edit row and insert the textbox with data in edit row to make rows editable.


2 Answers

Use <tbody> tags for this

like image 121
Ray Avatar answered Oct 21 '22 07:10

Ray


Give them a class name that is consistent then you can do:

$('table td.classname') 

To get the ones you want.

like image 30
matpol Avatar answered Oct 21 '22 07:10

matpol