相关疑难解决方法(0)

如何在div #content加载时显示div #loading

我想要实施一个解决方案,其中:

  1. 而div #content中的内容正在加载,
  2. 隐藏div #content,
  3. show div #loading,
  4. 然后当div #content加载时,
  5. hide div #loading,
  6. 淡出div #content

我试过了:

HTML:

<div id="content">
<!--this stuff takes a long time to load-->
<img src="http://lorempixel.com/1920/1920/">
</div>
<div id="loading">
<!-- this is the loading gif -->
<img src="http://lorempixel.com/400/200/">
</div>
Run Code Online (Sandbox Code Playgroud)

JS:

// when user browses to page
$('#content').hide();
$('#loading').show();

// then when div #content has loaded, hide div #loading and fade in div #content
$('#content').bind('load', function() {
$('#loading').hide();
$('#content').fadeIn('slow');
});
Run Code Online (Sandbox Code Playgroud)

这是我正在研究的jsfiddle:

http://jsfiddle.net/rwone/Y9CQ4/

谢谢.

html jquery loading

5
推荐指数
1
解决办法
3万
查看次数

标签 统计

html ×1

jquery ×1

loading ×1