zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jQuery实现table隔行换色和鼠标经过变色详解编程语言

jQuery编程语言 实现 详解 Table 鼠标 经过 变色
2023-06-13 09:20:28 时间
 $("tr:odd").css("background-color","#eeeeee"); 

 $("tr:even").css("background-color","#ffffff"); 

或者一行搞定:

 $("table tr:nth-child(odd)").css("background-color","#eeeeee"); 

:nth-child 匹配其父元素下的第N个子或奇偶元素

二、鼠标经过变色


 $("tr").bind("mouseover",function(){ 

 $(this).css("background-color","#eeeeee"); 

 $("tr").bind("mouseout",function(){ 

 $(this).css("background-color","#ffffff"); 

 }) 

当然live()和bind()都可以同时绑定多个事件或分开。

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/10065.html

cjava