Here is the code
https://jsfiddle.net/zdu1efrj/
$(document).ready( function() {
// start box animation code
let animatedBox = $('.box');
animatedBox.css('backgound', 'red');
animatedBox.animate(
{
left: '500px',
height: '250px',
width: '250px'
}, 1000);
animatedBox.css('background', 'blue');
animatedBox.animate(
{
top: '500px',
height: '100px',
width: '100px'
}, 1000);
// end box animation code
});
I want the box in the animation to be red as long as it moves vertically then change its color to blue and moves down.
why isn't the code executed in sequence ?
why animatedBox.css('background', 'blue');
seems to be executed before the completion of
animatedBox.animate(
{
left: '500px',
height: '250px',
width: '250px'
}, 1000);```
?