Passing dynamic CSS to jQuery.animate

Posted by harpo on Stack Overflow See other posts from Stack Overflow or by harpo
Published on 2010-04-07T15:44:34Z Indexed on 2010/04/07 16:13 UTC
Read the original article Hit count: 440

Filed under:

The documentation of jQuery.animate states that

The only required parameter is a map of CSS properties. This map is similar to the one that can be sent to the .css() method, except that the range of properties is more restrictive.

So, why does this work

$('#con div').css( {
        top : function(i) {
            console.log(i);
            return (i * 500) + 'px';
        }
    }
);

and this doesn't?

$('#con div').animate( {
        top : function(i) {
            console.log(i);
            return (i * 500) + 'px';
        }
    }
);

The console shows that the function is being evaluated for css, but not for animate. Am I missing something?

By the way, I'm using 1.4.2.

© Stack Overflow or respective owner

Related posts about jquery-animate