一段代码:
<script type="text/javascript">
$(function() {
$("#ctl00_ContentPlaceHolder1_GridViewProduct tr").mousemove(function() {
$(this).css("background", "#f3f9ff").siblings().css("background", "white");
})
})
</script>这样当鼠标放到某行是背景变色,其他行是白色背景。但原来的table里本身分奇偶行背景色的,比如1,3,5 是红色,2,4,6是蓝色,鼠标放上去高亮后,其他行就是白色了,不是原来的背景色。如何保持原来的奇偶行背景色的前提下实现高亮显示?
<script type="text/javascript">
$(function() {
$("#ctl00_ContentPlaceHolder1_GridViewProduct tr").mousemove(function() {
$(this).css("background", "#f3f9ff").siblings().css("background", "white");
})
})
</script>这样当鼠标放到某行是背景变色,其他行是白色背景。但原来的table里本身分奇偶行背景色的,比如1,3,5 是红色,2,4,6是蓝色,鼠标放上去高亮后,其他行就是白色了,不是原来的背景色。如何保持原来的奇偶行背景色的前提下实现高亮显示?
$(document).ready(function() {
$(".gridview tr:odd").addClass("odd"); //奇数行设定为 "odd" 样式
$(".gridview tr:even").addClass("even"); //偶数行设定为 "even" 样式
$(".gridview tr").mouseover(function() { $(this).addClass("over"); }) //当 mouseover 时加入 "over" 样式
.mouseout(function() { $(this).removeClass("over"); }) //当 mouseout 时移除 "over" 样式
.click(function() {
$(".gridview tr").removeClass("tr_chouse");
$(this).toggleClass("tr_chouse");
}); //当 click 加入或移除 "tr_chouse" 样式});