Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.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
Asp.net 使用jQuery设置gridview行_Asp.net_Jquery_Css_Gridview - Fatal编程技术网

Asp.net 使用jQuery设置gridview行

Asp.net 使用jQuery设置gridview行,asp.net,jquery,css,gridview,Asp.net,Jquery,Css,Gridview,我有一个表,它的类名为partnerGridClass。 我想设置与某个索引n对应的一行背景色。n只是一个javascript变量 $("table.partnerGridClass tbody tr:nth-child(n)").css("background-color", "#CCCCCC"); 我上面提到的不是选择第n行。有人知道怎么做吗?很明显,“n”必须用实际数字代替。因此,如果n是一个变量,则需要写入: $("table.partnerGridClass tbody tr:nth

我有一个表,它的类名为partnerGridClass。 我想设置与某个索引n对应的一行背景色。n只是一个javascript变量

$("table.partnerGridClass tbody tr:nth-child(n)").css("background-color", "#CCCCCC");

我上面提到的不是选择第n行。有人知道怎么做吗?

很明显,“n”必须用实际数字代替。因此,如果n是一个变量,则需要写入:

$("table.partnerGridClass tbody tr:nth-child(" + n + ")").css("background-color", "#CCCCCC");
即使这样,也要记住它是从1开始的,所以如果n=0是第一个,那么您需要先向它添加一个。

试试看

$("table.partnerGridClass tbody tr:nth-child("+n+")")