I want to animate background from coloured to transparent. I have code like this:
$('.selector')
.animate({
'background-color' : 'transparent'
}, 2000, function () {
$(this).css({ 'background-color' : '' });
});
It is quite complicated, because:
I need to remove the
style=""
after the animation finishes, because otherwise thestyle
would keep overriding the CSS class set by the.hover
handler. So I used this trick: jQuery - remove style added with .css() functionI don't know of any neater way to wait for effects to complete in jQuery, see: How to wait for effect queue to complete in jQuery call sequence
So, is there any simpler solution? Some more clever use of jQuery effects which wouldn't be so complicated?
I also tried the trick with .animate(,1)
:
$('.selector')
.animate({
'background-color' : 'transparent'
}, 2000)
.animate({'background-color': ''}, 1);
but it doesn't work in this case.