Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何设置表中的子编号_Jquery_Css_Html Table_Css Selectors - Fatal编程技术网

Jquery 如何设置表中的子编号

Jquery 如何设置表中的子编号,jquery,css,html-table,css-selectors,Jquery,Css,Html Table,Css Selectors,我可以用这种方式手动给childs打电话 $("tr>td:nth-child(1) tr:nth-child(n+3)").addClass("ClassName"); 如何传递这个值,比如说在javascript中 var index = 5; $("tr>td:nth-child(1) tr:nth-child("'+index+'")").addClass("ClassName"); 试过这种方法,它不起作用。我的情况是我们必须找到特定列的索引并传

我可以用这种方式手动给childs打电话

     $("tr>td:nth-child(1) tr:nth-child(n+3)").addClass("ClassName");
如何传递这个值,比如说在javascript中

   var index = 5;
    $("tr>td:nth-child(1) tr:nth-child("'+index+'")").addClass("ClassName");
试过这种方法,它不起作用。我的情况是我们必须找到特定列的索引并传递该索引值。如何修复上述代码

$("tr>td:nth-child(1) tr:nth-child(" + index + ")").addClass("ClassName");
为了完整性,我更喜欢@undefined方法:

$("tr>td:nth-child(1) tr").eq(zeroBasedIndex)

没有字符串格式错误:)

您没有正确连接值,我建议改用该方法<代码>$(“tr>td:n子(1)tr”).eq(zeroBasedIndex)$('tr[data uid=“”+row.uid+“]td')).eq(woIndex).css(“背景色”,“黄色”);。。。这是无效的$('tr[data uid=“'+row.uid+'“]td').eq(index.css(“背景色”,“黄色”);。。它不能以这种方式工作选择器应该可以工作,只是在一个非常简单的示例中尝试了它,所以一定还有其他事情在进行,您应该尝试构建一个示例:)我可以根据列名称而不是索引设置颜色吗?您可以做一些类似于
var col=$('tr[data uid=“”+row.uid+“]td').eq(index);col.css(“background color”,col.attr('name'))
这很好,但是在这里,当我们设置这个时,我在网格中有了分组功能,因为索引改变了它对不同颜色的设置