I have some boxes
<div class='ICS_Picture'>
Text
</div>
<div class='ICS_Picture'>
Text
</div>
<div class='ICS_Picture'>
Text
</div>
<div class='ICS_Picture'>
Text
</div>
I want jquery to add a class to all items after the first n number of items..
I have some similar code that does it for tr’s but cannot get the syntax right for the current item.
$('.ICS_Picture').each(function(){
$(this).addClass("hideme");
});
Thanks
Chris
With n being the number of elements to which you wish to apply the class. So if you want to apply it to the first four elements, n = 4.
EDIT–
I just reread the question and OP is looking to apply the styles to items AFTER a certain number. In that case, please use this instead:
Please note the n-1 because the indexing is zero-based and so if you want to start applying the styles after the 4th element you’ll need to ensure that the value you provide is 3. Obviously, standard concatenation rules will apply if you plan for n to be a dynamic value rather than hard-coded.