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
精彩评论