欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)table隔行換色和鼠標(biāo)經(jīng)過(guò)變色的兩種方法

 更新時(shí)間:2014年06月15日 10:03:22   投稿:whsnow  
這篇文章主要介紹jQuery實(shí)現(xiàn)table隔行換色和鼠標(biāo)經(jīng)過(guò)變色的兩種方法,需要的朋友可以參考下
一、隔行換色
復(fù)制代碼 代碼如下:

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

或者一行搞定:
復(fù)制代碼 代碼如下:

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

:nth-child 匹配其父元素下的第N個(gè)子或奇偶元素

二、鼠標(biāo)經(jīng)過(guò)變色
復(fù)制代碼 代碼如下:

$("tr").live({
mouseover:function(){
$(this).css("background-color","#eeeeee");
},
mouseout:function(){
$(this).css("background-color","#ffffff");
}
})

或者
復(fù)制代碼 代碼如下:

$("tr").bind("mouseover",function(){
$(this).css("background-color","#eeeeee");
})
$("tr").bind("mouseout",function(){
$(this).css("background-color","#ffffff");
})

當(dāng)然live()和bind()都可以同時(shí)綁定多個(gè)事件或分開(kāi)。

相關(guān)文章

最新評(píng)論