Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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_Indexing_Selector - Fatal编程技术网

在jQuery选择器中定义数组索引

在jQuery选择器中定义数组索引,jquery,indexing,selector,Jquery,Indexing,Selector,我的HTML标记中有几个表没有任何属性,我想知道:是否可以定义一个jQuery选择器来直接选择第三个表?是的,您可以从jQuery使用它 $('table').eq(2).css('background-color','red')例如,它获取第三个表(基于零的计数,jquery从零开始计数),并给它一个红色背景色 除了Tim的答案之外,您还可以在选择器中使用一个版本,例如: $("#myContainer table:eq(2) tr")

我的HTML标记中有几个表没有任何属性,我想知道:是否可以定义一个jQuery选择器来直接选择第三个表?

是的,您可以从jQuery使用它


$('table').eq(2).css('background-color','red')例如,它获取第三个表(基于零的计数,jquery从零开始计数),并给它一个红色背景色

除了Tim的答案之外,您还可以在选择器中使用一个版本,例如:

$("#myContainer table:eq(2) tr")