Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animating to another background-color, then back again

I'm trying to make my white background flash green. Currently I have this code which turns it green:

$( "#modal_newmessage" ).animate({
    backgroundColor: "#8bed7e"
}, 500 );

However, I can't figure how to make it turn white again in the same animation. How do I do this?

like image 965
Patrick Reck Avatar asked Dec 12 '25 14:12

Patrick Reck


1 Answers

You can chain another .animate() call since the animations will be queued in the fx queue.

$("#modal_newmessage").animate({
  backgroundColor: "#8bed7e"
}, 500).animate({
  backgroundColor: "#fff"
}, 500);

Remember most jQuery functions are chainable without need to call $("#modal_newmessage") twice.

See it here.

like image 138
Alexander Avatar answered Dec 14 '25 04:12

Alexander