user892239
user892239

Reputation: 149

Jquery show div for 10 seconds

  $(window).load(function(){
  $("#loading").show(10); //it was hide but changed to show, not working


  <div id="loading">
  Loading content, please wait..
  <img src="loading.gif" alt="loading.." />
  </div>

how can I get this loading bar to show for 10 seconds?

any help is greatly appreciated!

Upvotes: 3

Views: 21757

Answers (6)

TKV
TKV

Reputation: 2663

You can add this code...

$("#loading").show(10000,function(){
$("#loading").hide();
});

<div id="loading" style="display:none;">
  Loading content, please wait..
<img src="loading.gif" alt="loading.." />
</div>

this will display the div only for 10 second.. after 10 second div will disappear..

Upvotes: 0

Jamiec
Jamiec

Reputation: 136239

 $('#loading').delay(10000).fadeOut();

If you dont want to fade out you can also do

 $('#loading').delay(10000).queue(function(){ $(this).hide();$(this).dequeue(); });

Docs:

Upvotes: 4

Bhanu Krishnan
Bhanu Krishnan

Reputation: 3726

Use Jquery delay

   $("#loading").show().delay( 10000 ).hide();

Upvotes: 3

Artur Keyan
Artur Keyan

Reputation: 7683

$('#loading').animate({ opacity: 1 }, 10000);

Upvotes: 1

user113716
user113716

Reputation: 322612

If you meant that it's currently showing, and you want it to hide after 10 seconds, do this:

$("#loading").delay(10000).hide(0);

Or if you actually wanted an animation with the .hide(), add a longer duration:

$("#loading").delay(10000).hide(400);

Upvotes: 11

Prisoner
Prisoner

Reputation: 27638

setTimeout(function(){ $("#loading").fadeOut(); }, 10000);

Upvotes: 3

Related Questions