- 论坛徽章:
- 0
|
table 奇偶行背景色 鼠标移动行颜色变化
Java代码- 1. <STRONG>//设置table中偶数行的背景色</STRONG>
- 2.
- 3.$("#tableID tr:nth-child(even)").css({"background-color":"#E4F5FF"});
- 4.
- 5.<STRONG>//绑定事件当鼠标放到元素上背景颜色,
- 6.以及鼠标移开时背景颜色(会根据奇偶行判断设置不同的背景色)</STRONG>
- 7.
- 8. $("#tableID tr").mouseover(function(){
- 9. $(this).css({"background-color":"#87CEEB"});
- 10. }).mouseout(function(event){
- 11. var $index=$(this).index();
- 12. if($index%2==0){
- 13. $(this).css({"background-color":"#fff"});
- 14. }else{
- 15. $(this).css({"background-color":"#E4F5FF"});
- 16. }
- 17.
- 18. });
复制代码 |
|