开发者

How to run two jQuery animations on a single element simultaneously

We can write a single line of co开发者_Python百科de only if the animation functions are same, like animate( {top: "50px", opacity: 0} ), but how do you perform the animations simultaneously if the animation functions are different, say slide up and animate( {top: "50px"} )?


When calling to .animate() set the queue value to false, which will cause all animations to run at the same time.

$('div').animate({
    opacity: 0.25,
    height: '400px',
}, {
    queue: false,
    duration: 5000
}).animate({
    width: '500px'
}, {
    queue: false,
    duration: 5000
});

Example on jsfiddle

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜