I have a div with the id ring-preview, it has a unspecifed number of img elements with the class stone-preview inside it.
div
ring-preview
img
stone-preview
You can use a .each() in these cases, like this:
$("#ring-preview img.stone-preview").each(function(i) { $(this).rotate(ring.stones[i].stone_rotation); });
The first parameter to the callback function is the index you're after.