I need to animate a sliding with jquery. but only for 3 times. I wrote this code. But this more than 3 times. Please help me to fix or give different codes. Thanks in advance.

```
$(document).ready (function () {
    var i=0;
    while (i<3) {                    
        $('a.nextbtn').click (function () {
            $('ul.post-cat-sliding').stop().animate({"left": "-=596"},1500);
        });
        i++;
    }
});

```

and also i have previous button.. so if i click previous button slide should go back.