user3723240
user3723240

Reputation: 393

How to hide each item except first one?

I have 3 divs called .pageSection, I have a jquery each that hides each item, but I do not want to hide the first item, how would I do this? I tried the following, still hads all items, no errors:

$('.pageSection').each(function(){
    if($(this).not(":eq(0)")){
         $(this).hide();
     }
});

Upvotes: 1

Views: 81

Answers (1)

j08691
j08691

Reputation: 207943

No .each() needed. Use :gt() instead:

$('.pageSection:gt(0)').hide();

Upvotes: 7

Related Questions