2

I am trying to hide all elements with class .dropdown-menu except the 2nd one:

$('.dropdown-menu').not().eq(1).hide();

But it's not working, How to do this?

4

1 回答 1

3

尝试这个:

$('.dropdown-menu:not(:eq(1))').hide();

您正在使用:not incorecctly,这是使用:not的解决方案(它接受选择器!):

$('.dropdown-menu').not(':eq(1)').hide();
于 2013-10-16T18:43:09.180 回答