【问题标题】:Selecting children without a certain index (Jquery)选择没有特定索引的孩子(Jquery)
【发布时间】:2011-12-03 08:49:26
【问题描述】:
我想选择一些没有特定索引的孩子,比如反向使用 eq()。
我还需要能够将索引号作为变量传递。
【问题讨论】:
标签:
javascript
jquery
children
【解决方案1】:
$("#foo").children().not(":eq(2)");
这会选择foo 的所有孩子,除了第三个(eq() 使用 Javascript 的从 0 开始的索引)。
Example.
传递一个变量给它:
var num = "2";
$("#foo").children().not(":eq(" + num + ")").css("background-color", "red");
Example