简体   繁体   中英

how to add preloader for 3 seconds

I need to run a loader (#loading) for 3 seconds . is the below script correct?

 <script> <script language="javascript" type="text/javascript"> $(window).load(function(){ $('#loading').show();3000); }); </script> 

也许您不需要'$(window).load()'。

 $('#loading').show().delay(3000).hide() 

You need to remove the script tag.

You can use setTimeout() to remove something after 3 seconds.

 $(document).ready(function(){ setTimeout(function() { $('#loading').fadeOut(); }, 3000); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="loading"> Look at me, I'm a load screen </div> 

$('#loading')。show()。delay(3000).fadeOut(400);

像这样做:

$('#loading').show(0).delay(3000).hide(0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM