I want to animate 2 things at same time when mouse hovers something.
for example I want to change background color of box1 with id = “box1″ and position of box2 with id=”box2″ when mouse hovers a div with id=”trigger”.
but I don’t want them to animate in a queue, i.e. one after another. I want them to start animating at same time and finish at same time!
You can just run them in a row, like this:
This uses
.hover()to animate one way when hovering, and animate them back when leaving. The.stop()is just to prevent animation queue build-up. To animate a color, you’ll need either the color plugin, or jQuery UI included as well.Animations in jquery,
.animate(), are implemented usingsetInterval()with a 13ms timer, so they’ll happen outside the normal flow…doing them like above doesn’t wait for the first to finish, they’ll run simultaneously.