How to set the id for a set of <tr>s in a table
I'm having a table with tr generating in a loop
<table>
<div id="trresults">
{FOR LOOP}
<tr>
<td>sample text</td>
<td>sample text</td>
<td>sample text</td>
</tr>
<tr>
<td>sample text</td>
<td>sample text</td>
<td>sample text</td>
</tr>
{END FOR LOOP}
</div>
</table>开发者_JS百科
I want to group the tr's and set a id for that. So that I used div for that, but div will not work as in table all the items should be inside td's. So how can I solve this problem?
You can use a TBODY element to group your rows
<table>
<tbody id="trresults1">
{FOR LOOP}
<tr><td>for loop message</td></tr>
{END FOR LOOP}
</tbody>
<tbody id="trresults2">
{FOR LOOP}
<tr><td>for loop message</td></tr>
{END FOR LOOP}
</tbody>
</table>
Reference: Mozilla HTML Reference
<tbody>
<table>
精彩评论