HTML
<hr />
<h1>Table-1</h1>
<hr />
<table class="tb1">
<tr>
<td>rw1</td>
<td>rw1</td>
<td>rw1</td>
</tr>
<tr>
<td>rw1</td>
<td>rw1</td>
<td>rw1</td>
</tr>
<tr>
<td colspan="3">
<table class="tb2">
<tr>
<td>tbrw2</td>
<td>tbrw2</td>
<td>tbrw2</td>
</tr>
<tr>
<td>tbrw2</td>
<td>tbrw2</td>
<td>tbrw2</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>rw1</td>
<td>rw1</td>
<td>rw1</td>
</tr>
<tr>
<td colspan="3">
<table class="tb2">
<tr>
<td>tbrw2</td>
<td>tbrw2</td>
<td>tbrw2</td>
</tr>
<tr>
<td>tbrw2</td>
<td>tbrw2</td>
<td>tbrw2</td>
</tr>
</table>
</td>
</tr>
</table>
<hr />
<h1>Table-2</h1>
<hr />
<table class="tb1">
<tr>
<td>rw1</td>
<td>rw1</td>
<td>rw1</td>
</tr>
<tr>
<td>rw1</td>
<td>rw1</td>
<td>rw1</td>
</tr>
<tr>
<td colspan="3">
<table class="tb2">
<tr>
<td>tbrw2</td>
<td>tbrw2</td>
<td>tbrw2</td>
</tr>
<tr>
<td>tbrw2</td>
<td>tbrw2</td>
<td>tbrw2</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>rw1</td>
<td>rw1</td>
<td>rw1</td>
</tr>
<tr>
<td colspan="3">
<table class="tb2">
<tr>
<td>tbrw2</td>
<td>tbrw2</td>
<td>tbrw2</td>
</tr>
<tr>
<td>tbrw2</td>
<td>tbrw2</td>
<td>tbrw2</td>
</tr>
</table>
</td>
</tr>
</table>
CSS
.tb1{
border-collapse:collapse;
}
.tb1 tr td {
border-bottom:1px solid #ccc;
text-align:center;
padding:10px;
}
.tb2{
border-collapse:collapse;
}
.tb2 tr td {
border-bottom:1px solid #f00;
text-align:center;
padding:10px;
}
JQUERY
$(".tb1 tr:last-child td,.tb2 tr:last-child td").css("border","none");
有很多像下面的图像,并使用jquery更改一些边框(我知道一点点jquery)但是边框有一些问题。 Jquery在最后一个tr中改变了所有td的边界。我对选择器错了。我该如何解决这个问题?
的jsfiddle
答案 0 :(得分:2)
试试这个,
$(function(){
$('table.tb2').find('tr td').css({'border-bottom':'1px solid red'});
$('table.tb2').find('tr:last td').css({'border-bottom':'none'});
$('table.tb2').closest('td').css({'border-bottom':'none'});
});
答案 1 :(得分:1)
尝试tr:last-child>td
仅影响最后一行内的细胞。
另请注意,您不应该使用jQuery。只需将其添加到您的CSS:
.tb1 tr:last-child>td,.tb2 tr:last-child>td {border:none}
答案 2 :(得分:0)
试试这个:
$(".tb2 tr:first-of-type").css("border-bottom","2px solid red");
我还将css更改为:
.tb2 tr td {
text-align:center;
padding:10px;
}
从原来的css:
.tb2 tr td {
border-bottom:1px solid #f00;
text-align:center;
padding:10px;
}
请参阅Demo