I'm struggling a little bit with a for loop in jquery. I have a div with the class `.row`. Inside that div there are a number of `.item` div's. I do not know the number of items in advance.

What i want is to start counting at **0** and end at **3**. Like (0,1,2,3,0,1,2,3...etc)

**HTML:**

```
<div class="row cl">
    <div class="item"></div>
</div>

```

**What i've tried:**

```
$('.row > .item').each(function(i){
    for(i=0;i<4;++i){
       // Here i want to add a class (repeatedly) if the index of the .item is 3.
    }
});

```

The result in the above example isn't working properly. I'm getting 3's everywhere. I know how to add a class it's all about the counting part.

> 
> I normally can use a CSS selector like `:nth-child()` but i need it to
>  work in IE 8, and that's not supporting all of the child selectors.
> 
> 
>