0

我有一个脚本,允许从页面加载一些内容,我只想在所有内容完全加载后执行一些东西。

我尝试使用此脚本,但在 IE 中似乎还不够:

$(".ajaxify_container").load('single.php?page='+url.substring(1)+' #single-container', null, function(){
    $(".Slide img").on("load", function () { 
        load_content_animation();
    });
})
4

2 回答 2

1

编辑 - 1

var $images = $(".Slide img"), imageCount = $images.length;
var counter;

$(".Slide img").on("load", function () { 
   counter++;
   if (counter == imageCount) {
       load_content_animation();
   }
});

原来的

我只想在所有内容都完全加载后才执行一些东西。

使用window load. 这将在所有内容下载完成后执行。

jQuery(window).load(function () {
   //Your code comes here
});
于 2013-06-16T19:55:19.290 回答
-1

包装你想要隐藏的内容,直到页面加载一个 div:

<div class="hide">
    <!-- Content hidden when page is loading -->
</div>

使用 CSS 隐藏内容:

.hide {
    display: none;
}

然后使用 JQuery 隐藏和显示内容:

jQuery(window).load(function() {
    $('.loading').fadeOut(1000);
    $('.hide').show();
});
于 2013-06-16T19:56:27.910 回答