Asp.net 使用jQuery设置gridview行
我有一个表,它的类名为partnerGridClass。 我想设置与某个索引n对应的一行背景色。n只是一个javascript变量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
$("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+")")