1

I'm trying to make a div background color to fadeOut slow

html

<div class="bg">...........</div>

I used this jquery

$('.bg').css('backgroundColor','#dedede');
setTimeout(function(){
    $('.bg').css('backgroundColor','#ffffff'); 
}, 1000);

How to add the fadeOut effect?

Devstar
  • 305
  • 1
  • 8
  • 21

1 Answers1

3

You can use fadeOut: $('.bg').css('backgroundColor', '#dedede');

$('.bg').fadeOut(1000);

Demo

OR

You can animate:

$('.bg').animate({
    'opacity': '0'
}, 1000);

Demo

UPDATE

$('.bg').css('backgroundColor', '#dedede');
$('.bg').animate({
    'opacity': '0.5'
}, 1000, function () {
    $('.bg').css({
        'backgroundColor': '#fff',
        'opacity': '1'
    });
});

Demo

Tushar
  • 85,780
  • 21
  • 159
  • 179