My table has id="mytable"
. I'm trying to apply some CSS on the first and last <th>
only. I tried this but it doesn't work.
我的表有id =“mytable”。我正在尝试在第一个和最后一个上应用一些CSS。我试过这个,但它不起作用。
#mytable th:first,
#mytable th:last{
//css goes here
}
2 个解决方案
#1
43
#mytable th:last-child, #mytable th:first-child {
//css goes here
}
#2
-2
For CSS
对于CSS
#myTable thead tr th:first,
#myTable thead tr th:last{
/*CSS goes here*/
}
Using Jquery (for last child only):
使用Jquery(仅限最后一个孩子):
$("#mytable th:last-child").css({
/*CSS goes here*/
});
#1
43
#mytable th:last-child, #mytable th:first-child {
//css goes here
}
#2
-2
For CSS
对于CSS
#myTable thead tr th:first,
#myTable thead tr th:last{
/*CSS goes here*/
}
Using Jquery (for last child only):
使用Jquery(仅限最后一个孩子):
$("#mytable th:last-child").css({
/*CSS goes here*/
});