图片加载后执行的代码
var ImgLoad = function (callback, e) {
var imgdefereds = [];
e.find('img').each(function () {
var dfd = jQuery.Deferred();
jQuery(this).bind('load', function () {
dfd.resolve();
}).bind('error', function () {
dfd.resolve();
});
if (this.complete) {
setTimeout(function () {
dfd.resolve();
}, 1000);
}
imgdefereds.push(dfd);
});
jQuery.when.apply(null, imgdefereds).done(function () {
callback();
});
};
调用
ImgLoad(function() {
// 需要执行的代码
},$("body") )
说明$("body")是图片的容器,里面就是需要的图片DNG.pageLoaders();需要执行的代码