简体   繁体   English

如何在第二页加载之前显示div一段时间

[英]How to show a div for a while before second page load

I have a div with name ADD . 我有一个名称为ADD的div。 and with this button i want to load a second page in present page with ajaxload. 并使用此按钮,我想用ajaxload在当前页面中加载第二页。 the question is how can i show a div for 4 second before load second page ?and after that 4 second the second page loads? 问题是如何在加载第二页之前显示div 4秒钟,然后在第二页加载4秒后显示div? here is my snippet : 这是我的片段:

  $(function() { $('.add').click(function() { $('.here').html('<span class="loading">LOADING...</span>'); $('.here').load('secondpage.html'); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <a href="javascript:void(0)" href="javascript "><div class="add">ADD Zone</div></a> <div class="here" style="border:1px solid #000; width:100%; height:400px;"> </div> 

You can use setTimeout : 您可以使用setTimeout

$(function() {
  $('.add').click(function() {
    $('.here').html('<span class="loading">LOADING...</span>');
    setTimeout(function() {
      $('.here').load('secondpage.html');
    }, 4000);
  });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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