AnchovyLegend
AnchovyLegend

Reputation: 12538

fadeOut an element after it has been shown for some time

I am trying to have the .status-bar appear %100 for a set time interval and then start to fade away when the time interval expires. The problem I am having is, right now as soon as the code below executes the status bar appears and starts fading away instantly (please note that the code below is part of a bigger click function).

I was wondering if someone can help me identify what I need to do to accomplish this.

setTimeout(function(){
     $(".status-bar").show();
     $(".status-bar").fadeOut(5000, function () {

    });
}, 0);

Many thanks in advance!

Upvotes: 0

Views: 39

Answers (1)

coder
coder

Reputation: 13250

Don't use setTimeout. Insead of that use delay()

$('.status-bar"').delay(2000).fadeOut();

Upvotes: 1

Related Questions