2011-12-03 21 views

回答

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

这将选择的foo所有的孩子,除了3号一个(eq()使用JavaScript的基于0的索引)。

Example

要将变量传递给它:

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

Example

+0

谢谢,我将如何传递一个变量? –

+0

你是什么意思? 'eq()'中的数字将是一个变量? – Purag

+0

像这样:http://jsfiddle.net/wEGrp/1/ –