jQuery实现table隔行换色和鼠标经过变色
2014-12-08 17:26
561 查看
jQuerytable隔行换色鼠标经过变色
一、隔行换色
$("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").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()都可以同时绑定多个事件或分开。
一、隔行换色
$("tr:odd").css("background-color","#eeeeee");
$("tr:even").css("background-color","#ffffff");
$("tr:odd").css("background-color","#eeeeee"); $("tr:even").css("background-color","#ffffff");或者一行搞定:
$("table tr:nth-child(odd)").css("background-color","#eeeeee");
$("table tr: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").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");
})
$("tr").bind("mouseover",function(){ $(this).css("background-color","#eeeeee"); }) $("tr").bind("mouseout",function(){ $(this).css("background-color","#ffffff"); })
当然live()和bind()都可以同时绑定多个事件或分开。
相关文章推荐
- jQuery实现table隔行换色和鼠标经过变色的两种方法
- jQuery实现table隔行换色和鼠标经过变色
- jQuery实现table隔行换色和鼠标经过变色
- jQuery实现table隔行换色和鼠标经过变色的两种方法
- jQuery实现table隔行换色和鼠标经过变色
- jQuery实现table隔行换色和鼠标经过变色
- jQuery实现table隔行换色和鼠标经过变色
- jquery实现table鼠标经过变色代码
- JQuery实现表格隔行变色,鼠标经过的行放大显示
- jQuery实现table表格隔行换色鼠标经过变色
- 用jquery实现单双行变色以及鼠标经过时也同时变色
- jQuery实现table表格隔行换色鼠标经过变色
- jquery实现table鼠标经过变色代码
- JQuery实现table隔行变色及鼠标滑动变色
- Jquery实现GridView隔行变色,鼠标经过变色,单击或者选中变色
- CSS+DIV实现鼠标经过背景变色
- 分享一个jquery插件:实现类似淘宝上鼠标经过图片右侧显示大图的效果
- 表格隔行变色_jQuery控制实现鼠标悬停高亮
- 鼠标经过背景变色,CSSJavascript实现表格背景变色
- jQuery实例--实现斑马线效果包括鼠标的移入移出变色