http://blog.dj5.cn/uploads/20230414/42e29256f1ba80afb3ad6f92f5452b47.rar
完整:
$('#container').imagesLoaded()
.always( function( instance ) { //always事件,在所有图片都加载完成(成功与否不论)时触发
console.log('all images loaded');
})
.done( function( instance ) { //done事件,在所有图片都加载成功时触发
console.log('all images successfully loaded');
})
.fail( function() { //fail事件,在所有图片都加载完成,并且至少有一张图片加载失败时触发
console.log('all images loaded, at least one is broken');
})
.progress( function( instance, image ) { //progress事件,在每一张图片加载完成时都触发一次
var result = image.isLoaded ? 'loaded' : 'broken'; //判断当前图片加载成功与否
console.log( 'image is ' + result + ' for ' + image.img.src );
});
简单用法$('#container').imagesLoaded( function() {
// images have loaded
});
// options
$('#container').imagesLoaded( {
// options...
},
function() {
// images have loaded
}
);
背景:
// jQuery
$('#container').imagesLoaded( { background: true }, function() {
console.log('#container background image loaded');
});
背景子元素// jQuery
$('#container').imagesLoaded( { background: '.item' }, function() {
console.log('all .item background images loaded');
});
发表评论 取消回复