简体   繁体   English

选择没有特定索引的子项(jQuery)

[英]Selecting children without a certain index (Jquery)

I want to select some children without a certain index like using eq() in reverse. 我想选择一些没有特定索引的孩子,例如反向使用eq()。

I also need to be able to pass the index number as a variable . 我还需要能够将索引号作为变量传递。

$("#foo").children().not(":eq(2)");

This selects all children of foo except the 3rd one ( eq() uses Javascript's 0-based indexing). 这将选择foo所有子项,但第三个除外( eq()使用Javascript基于0的索引)。

Example . 例子

To pass a variable to it: 要将变量传递给它:

var num = "2";
$("#foo").children().not(":eq(" + num + ")").css("background-color", "red");

Example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM