style type="text/css"> 
     th {background-color: red;} 
</style> 
<script type="text/javascript" src="JScript/jquery-1.5.1.min.js" ></script> 
<script type="text/javascript"> 
    $(function() { 
          $("#tbl tr:nth-child(even)").css("background-color","orange"); 
          $("#tbl tr:nth-child(odd)").css("background-color","green");  
     }) 
</script><table id="tbl" border="1">
 <tr>
  <th>姓名</th>
  <th>年龄</th>
  <th>所属组</th>
 <tr>
<logic:empty name="userList">
 <tr id="emptyTr">
  <td colspan="3">没有成员</td>
 <tr>
</logic:empty>
<logic:notEmpty name="userList">
  <logic:iterate id="u" name="userList">
     <tr>
  <td><bean:write name="u" property="username"/></td>
  <td><bean:write name="u" property="age"/></td>
  <td><bean:write name="u" property="group.name"/></td>
     <tr>
  </logic:iterate>
</logic:notEmpty>
</table>

解决方案 »

  1.   

    tr元素结束标记写错了……<tr>
    <th>姓名</th>
    <th>年龄</th>
    <th>所属组</th>
    </tr>
      

  2.   

    <html>
    <style type="text/css"> 
      th {background-color: red;} 
    </style> 
    <script type="text/javascript" src="jquery-1.4.4.min.js" ></script> 
    <script type="text/javascript"> 
      $(function() { 
      $("#tbl tr:nth-child(even)").css("background-color","orange"); 
      $("#tbl tr:nth-child(odd)").css("background-color","green");  
      }) 
    </script><table id="tbl" border="1">
    <tr>
    <th>姓名</th>
    <th>年龄</th>
    <th>所属组</th>
    </tr>
    <logic:empty name="userList">
    <tr id="emptyTr">
    <td colspan="3">没有成员</td>
    </tr>
    </logic:empty>
    <logic:notEmpty name="userList">
    <logic:iterate id="u" name="userList">
    <tr>
    <td><bean:write name="u" property="username"/></td>
    <td><bean:write name="u" property="age"/></td>
    <td><bean:write name="u" property="group.name"/></td>
    </tr>
    </logic:iterate>
    </logic:notEmpty>
    </table>
    </html>这样应该就可以了
      

  3.   


    <html>
    <style type="text/css"> 
      th {background-color: red;} 
    </style> 
    <script type="text/javascript" src="jquery-1.4.4.min.js" ></script> 
    <script type="text/javascript"> 
      $(function() { 
      $("#tbl tr:nth-child(even)").css("background-color","orange"); 
      $("#tbl tr:nth-child(odd)").css("background-color","green");  
      }) 
    </script><table id="tbl" border="1">
    <tr>
    <th>姓名</th>
    <th>年龄</th>
    <th>所属组</th>
    </tr>
    <logic:empty name="userList">
    <tr id="emptyTr">
    <td colspan="3">没有成员</td>
    </tr>
    </logic:empty>
    <logic:notEmpty name="userList">
    <logic:iterate id="u" name="userList">
    <tr>
    <td><bean:write name="u" property="username"/></td>
    <td><bean:write name="u" property="age"/></td>
    <td><bean:write name="u" property="group.name"/></td>
    </tr>
    </logic:iterate>
    </logic:notEmpty>
    </table>
    </html>
      

  4.   

    晕了,重点不是那个,我只是贴一部分代码程序是将第三行的颜色变为蓝色,然后再执行
    <logic:iterate id="u" name="userList">
    这样就将循环的行数全变成了蓝色有什么办法先执行完<logic:iterate id="u" name="userList">得到行数,
    然后再将循环出来的行,实现隔行变色呢?没人知道么?