jQuery animation problem

I have relatively positioned list items in a list, I’m trying to animate them and when the element goes beyond the container I want to return it to container’s starting point, here’s a code, animation seems to be working but when I do the check (if the element is out of container) in the callback and I try to change the css of the current element it doesn’t do anything, element stays in the same place and continues to move in the same direction.

here’s my code:

var lis = $  ("#container").find('li');
(function(){
    var curFunc = arguments.callee;
    lis.animate({
            left:"+=1px"
    },10,function(){
        var currentLi = $  (this);
        if(currentLi.position().left > 995){
            currentLi.css({"left" : "-=900px"});
        }
        curFunc();
    });
})();

newest questions tagged jquery – Stack Overflow

About Admin