标签:
<!--js效果-->
<script src="js/jquery.min.js" language="javascript"></script>
<script>
$(document).ready(function(){
///////datagrid选中行变色与鼠标经过行变色///////////////
var dtSelector = ".list";
var tbList = $(dtSelector);
tbList.each(function() {
var self = this;
$("tr:even:not(:first)", $(self)).addClass("normalEvenTD"); // 从标头行下一行开始的奇数行,行数:(1,3,5...)
$("tr:odd", $(self)).addClass("normalOddTD"); // 从标头行下一行开始的偶数行,行数:(2,4,6...)
// 鼠标经过的行变色
$("tr:not(:first)", $(self)).hover(
function () { $(this).addClass(‘hoverTD‘);$(this).removeClass(‘table-td-content‘); },
function () { $(this).removeClass(‘hoverTD‘);$(this).addClass(‘table-td-content‘); }
);
// 选择行变色
$("tr", $(self)).click(function (){
var trThis = this;
$(self).find(".trSelected").removeClass(‘trSelected‘);
if ($(trThis).get(0) == $("tr:first", $(self)).get(0)){
return;
}
$(trThis).addClass(‘trSelected‘);
});
});
});
</script>
<!--表格代码-->
<table width="100%" class="list" style="word-break: break-all" border="0"
align="center" cellpadding="0" cellspacing="1" bgcolor="#e4e5e5">
<tr class="table-tr-title">
<td width="5%">姓名</td>
<td width="5%">授权级别</td>
<td width="5%">经销商手机号</td>
</tr>
<tr class="table-tr-content">
<td width="5%">谈重海</td>
<td width="5%">一级代理</td>
<td width="5%">156230152416</td>
</tr>
<tr class="table-tr-content">
<td width="5%">数据</td>
<td width="5%">数据</td>
<td width="5%">数据</td>
</tr>
<tr class="table-tr-content">
<td width="5%">数据</td>
<td width="5%">数据</td>
<td width="5%">数据</td>
</tr>
<tr class="table-tr-content">
<td width="5%">数据</td>
<td width="5%">数据</td>
<td width="5%">数据</td>
</tr>
<tr class="table-tr-content">
<td width="5%">数据</td>
<td width="5%">数据</td>
<td width="5%">数据</td>
</tr>
</table>
<!--css样式表-->
.table-tr-title{ font-weight:bold;
height: 26px;
font-size: 16px; font-family:"微软雅黑"; line-height:36px;
text-align: center;
}
.table-tr-content{line-height:32px; font-size:14px; font-family:"微软雅黑";
height: 18px; color:#676767;
background: #FFFFFF;
text-align: center;
font-size: 12px;
}
.normalEvenTD{
background: #e9e8e8;
}
.normalOddTD{
background: #FFFFFF;
}
.hoverTD{
background-color: #d2d0d0;
height: 18px;
text-align: center;
font-size: 12px;
}
.trSelected{
background-color: #51b2f6;
height: 18px;
text-align: center;
font-size: 12px;
}
标签:
原文地址:http://www.cnblogs.com/dingyufenglian/p/4812861.html