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?
2 Answers
Use <tbody> tags for this
5 Comments
Ricardo Marimon
Can you have multiple tbodys to group the rows. I've though that you had one thead, one tbody, and one tfoot per table.
Ray
Multiple tbdodys are fine. You are correct that only one thead and tfoot are allowed.
amaster
<tbody> tags do not support everything that other tags do such as padding and margin, for these situations, @matpol has the better solution, but this is the best solution to the question from the OP unless under these special circumstances.Ciro Santilli OurBigBook.com
Beware of automatic
tbody addition stackoverflow.com/questions/938083/… and add all those tbody elements explicitly on the HTML.Mike de Klerk
what about nested tbody for the purpose of grouping rows above a tbody and those within?
Give them a class name that is consistent then you can do:
$('table td.classname')
To get the ones you want.
2 Comments
Tomasz Gandor
In the old days retrieving elements by class name could be unacceptably slow on some browsers. Today it's usually built into the DOM.
Alnitak
shouldn't this be
tr.classname ?