JQUERY 选择 TABLE 中的列

来源:互联网 发布:lisa大额头 知乎 编辑:程序博客网 时间:2024/05/16 18:04

JQUERY 列选择器
先来一个经典的:
$("table tr").find("td:first").html(11);
//错误写法:$("table tr td:first").html(11);
这应该算是一个BUG吧!
再来一个更经典的:
$("table tr").each(function(){
 $(this).find("td:eq(1)").html(22);      
})
来两个特别的:
$("table tr td:first-child").html("first");
$("table tr td:last-child").html("last");
最后来点专业的!:
$("table tr td:nth-child(3)").html(33)
$("table tr td:nth-child(odd)").html(44)
$("table tr td:nth-child(even)").html(55)
$("table tr td:nth-child(3n+1)").html(66)