timpone
timpone

Reputation: 19939

jquery - 3 images to load on multiple instances of a class on a single page

I asked this question earlier today jQuery - showing first three images of a gallery; hiding the remainder but when testing out other pieces and reseeding, I realized that the sol'n only worked for the first image-container-box. Unfortunately, I'll be having multiple image-container-box's per page. Is there a way to tell jquery each of the image-container-box rather than just the first? Or, did I misunderstand the accepted answer?

thx

Upvotes: 0

Views: 106

Answers (1)

mrtsherman
mrtsherman

Reputation: 39872

You will have make use of jQuery's each to apply the slicing code to each one.

$('.image-container-box').each( function() { 
    $(this).children('.image-box').slice(2).hide(); //or use find if image-box isn't a direct descendent of image-container-box
});

Upvotes: 1

Related Questions