开发者

How to run two jQuery animations on a single element simultaneously

开发者 https://www.devze.com 2023-03-30 19:04 出处:网络
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 a

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

精彩评论

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