How do I increment up to a specific number (3), then have it reset, looping back to the first number. The first number should begin at 1 (not 0).
I've tried using: i=1; i<=3; i+=1
Here's my basic code:
$(document).ready(function() {
$(".std-price .local-pricing").each(function(i) {
$(this).addClass("ab-price" + (i));
});
});
If I used for() or each(), it would then give me class="ab-price1 ab-price2 ab-price3"
Any help and reference links (to learn in the process) would be great.
Thanks!
$(".std-price .local-pricing").length||0. Or instead of a mod, just useif (i==0) { i = 1 }at the top of your function.