如何使用Jquery在Datatable中选择一列

如何使用Jquery在Datatable中选择一列,jquery,css,datatable,Jquery,Css,Datatable,我发现一个解决方案是浏览表中的每一行。但有更好的解决办法吗 $(document).ready(function() { $('table tr').each(function(){ $(this).find('td').eq(2).css('background-color', 'green'); }); }); 您不需要使用each()方法,只需使用jquery选择器即可 $('trtd:first child').css('background','#07

我发现一个解决方案是浏览表中的每一行。但有更好的解决办法吗

$(document).ready(function() {
    $('table tr').each(function(){
        $(this).find('td').eq(2).css('background-color', 'green');
    });
});

您不需要使用
each()
方法,只需使用jquery选择器即可

$('trtd:first child').css('background','#07C')

或用于第n列

$('tr td:nth-child(2)').css('background','#07C');
$(函数(){
$('trtd:nth child(2)').css('background','#5ae');
});

第一列
第二列
第三纵队
第一列
第二列
第三纵队
第一列
第二列
第三纵队

你能详细说明你想做什么吗。第二,您的标题是关于选择列,但您的回答是“我发现一个解决方案是浏览表中的每一行”,您是否尝试获取行或列?我想为数据表中的任何列插入css