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!