jQuery实现table隔行换色和鼠标经过变色的两种方法
$("tr:odd").css("background-color","#eeeeee");
$("tr:even").css("background-color","#ffffff");
或者一行搞定:
$("tabletr:nth-child(odd)").css("background-color","#eeeeee");
:nth-child匹配其父元素下的第N个子或奇偶元素
二、鼠标经过变色
$("tr").live({
mouseover:function(){
$(this).css("background-color","#eeeeee");
},
mouseout:function(){
$(this).css("background-color","#ffffff");
}
})
或者
$("tr").bind("mouseover",function(){
$(this).css("background-color","#eeeeee");
})
$("tr").bind("mouseout",function(){
$(this).css("background-color","#ffffff");
})
当然live()和bind()都可以同时绑定多个事件或分开。
热门推荐
10 新年过后奋斗祝福语简短
11 姐妹分手了祝福语简短
12 送情侣生日祝福语简短
13 最美母女祝福语简短英文
14 端午的祝福语毕业简短
15 法考面试祝福语简短
16 乘风语文考试祝福语简短
17 生日祝福语贺卡文字简短
18 中午生日家庭祝福语简短