jQuery在animate函数中设置css位置

Lee*_*Lee 0 javascript css jquery jquery-animate

你将如何设置position:relative中的元素属性,它不具有初始position属性集,内jQuery的animate()

这不起作用:

$(mLinks[id]).animate
(
    {
        position:'relative',
        left:'200px'
    }
);
Run Code Online (Sandbox Code Playgroud)

鉴于这mLinks是一个有效的DOM元素对象.

我也试过durationcallback参数.

lui*_*s90 5

"动画"css position属性是没有意义的不是吗?有没有之间的relativeabsolutestatic之类的东西......

这就是我要做的:

$(mLinks[id]).css('position', 'relative').animate
(
    {
        left:'200px'
    }
);
Run Code Online (Sandbox Code Playgroud)

如果你阅读了相应的jQuery文档,你会发现:

most properties that are non-numeric cannot be animated using basic jQuery functionality (For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color() plugin is used).