2012-08-04 78 views

回答

5

您可以使用:not():first选择:

$('.squares:not(:first)').addClass('border') 

或:

$('.squares:not(:first)').css('border-right', 'value') 
+0

您好,感谢。我只是有一点语法问题,因为我使用'this'选择器。我如何结合':not(:first)'?它是'$(this +':not(:first)')'。这没有奏效。 THanks – eric01 2012-08-04 03:07:56

+1

'this'是上下文,所以放在上下文的位置。 '$('selector',context)' – elclanrs 2012-08-04 03:08:28

+0

@ eric01嗨,不客气,':not'不行,如果你想取消选择第一个元素并且你的元素是兄弟,你可以试试这个:'' if($(this).index()!= 0)' – undefined 2012-08-04 03:16:03

3

你有没有使用:first:not()选择捆绑?

我没有测试过,但下面的代码应该做你想要什么:

$(".squares:not(:first)").css("border-right", "thin solid red"); 
2

使用.is()if声明:该

if (!$(this).is(".squares:first()")) { 
    // not the first square 
} 
相关问题