选择表列(jQuery) [英] Selecting table columns (jQuery)
本文介绍了选择表列(jQuery)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想给一些特定类的FIRST和LAST列的所有(包括< th>
)单元格,我试过这个:
I want to give ALL (including <th>
) cells of FIRST and LAST columns some specific classes, I tried this:
$("table tr:first-child td:first-child").addClass("first-col-cell");
$("table tr:last-child td:last-child").addClass("last-col-cell");
..但它似乎不起作用。
..but it doesn't seem to work.
非常感谢任何帮助。
推荐答案
编辑:你的选择器非常接近:
Your selector was pretty close:
<script type="text/javascript">
$(function() {
$("table tr td:first-child").text('hello');
$("table tr td:last-child").text('goodbye');
});
</script>
<table>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
这篇关于选择表列(jQuery)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文