标签:des style blog http os io 使用 java ar
imagesLoaded 是一个用于来检测网页中的图片是否载入完成的 JavaScript 工具库。支持回调的获取图片加载的进度,还可以绑定自定义事件。可以结合 jQuery、RequireJS 使用。
使用示例:
// element imagesLoaded( document.querySelector(‘#container‘), function( instance ) { console.log(‘all images are loaded‘); }); // selector string imagesLoaded( ‘#container‘, function() {...}); // multiple elements var posts = document.querySelectorAll(‘.post‘); imagesLoaded( posts, function() {...});
绑定自定义事件:
var imgLoad = imagesLoaded( elem ); function onAlways( instance ) { console.log(‘all images are loaded‘); } // bind with .on() imgLoad.on( ‘always‘, onAlways ); // unbind with .off() imgLoad.off( ‘always‘, onAlways );
本文链接:imagesLoaded – 检测网页中的图片是否加载
编译来源:梦想天空 ◆ 关注前端开发技术 ◆ 分享网页设计资源
标签:des style blog http os io 使用 java ar
原文地址:http://www.cnblogs.com/lhb25/p/javascript-for-images-loaded-detect.html