Question

I need to shake div and animate its background-color color at the same time.

Here is the JSFiddle example: http://jsfiddle.net/EUz4z/

$("#test").effect("shake", {}, 500 ).css("background-color","red").animate({backgroundColor: old_bg}, 500 );
})
Was it helpful?

Solution

You can use the queue: false option:

http://jsfiddle.net/ysFcD/

$(document).ready(function(){
    $("#but").click(function(){
        old_bg=$("#test").css("background-color");
        $("#test").effect("shake", {  }, 500 )
            .css("background-color","red")
            .animate({backgroundColor: old_bg}, {duration: 500, queue: false } );
    })
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top