开发者

How to set the id for a set of <tr>s in a table

开发者 https://www.devze.com 2023-02-03 09:14 出处:网络
I\'m having a table with tr generating in a loop <table> <div id=\"trresults\"> {FOR LOOP} <tr>

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号