我需要为我的 html 表格的交替行应用背景颜色。
我当前的代码:
.licList
{
width: 100%;
border: 1px solid #f7f7f7;
text-align: center;
border-collapse: collapse;
}
.licList th
{
font-weight: bold;
background-color: #dbdbdb;
border-bottom: 1px solid #f1f1f1;
padding: 4px 5px;
}
.licList td
{
padding: 4px 5px;
}
.odd
{
background-color: #ffffff;
}
.odd td
{
border-bottom: 1px solid #cef;
}
jquery 是
$(document).ready(function () {
$("licList:tr:odd").addClass("odd");
});
我确定上面的 jquery 不正确我在单个页面中有多个表所以我不能申请
$(document).ready(function(){
$("tr:odd").addClass("odd");
});
所以我的问题是如何解决这个问题????
最佳答案
jquery is not correct I've multiple tables in single page so I can't apply
为您的表分配一个 id/class
并访问该表下的行。假设你的表有 id tbl
<table id="tbl">
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
</tr>
</table>
$(document).ready(function(){
$("#tbl tr:odd").addClass("odd");
});
关于c# - 如何将CSS应用于表格行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14557566/