Skip to content

Instantly share code, notes, and snippets.

@nickberens360
Created March 23, 2017 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickberens360/9531086527078204586f377d7cb99588 to your computer and use it in GitHub Desktop.
Save nickberens360/9531086527078204586f377d7cb99588 to your computer and use it in GitHub Desktop.
Loop through elements with incrementing class name
var i = 0;
$('.picBoxGrid').find('.picBox').each(function () {
if (i < 4) {
i++;
}
else {
i = 1;
}
$(this).addClass('picBoxColor-' + i);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment