用CSS实现隔行变色的技术

.Pop_TR{
     background-color:expression(this.rowIndex%2==0 ? "一种颜色":"另一种颜色");
     cursor:hand;
}

 

<table>
//循环取列表
    <tr lcass="Pop_TR">
       <td></td>
    </tr>
//循环结束
</table>

 


JQuery的话也很简单

1.
通过定义俩个class来实现

$("tr:even").addClass("even-row"); 
$("tr:odd").addClass("odd-row"); 

 

2.
或者一行代码 

$("tr").each(function(i){this.style.backgroundColor['#ccc','#fff'][i%2]})   

  

 

你可能感兴趣的:(jquery,css)