
img
图片加载后执行的代码
DNN主题 • 舒正兴 发表了文章 • 0 个评论 • 554 次浏览 • 2020-12-29 14:53
$(document).ready(function() {$('pre code').each(function(i, block) { hljs.highlightBlock( block); }); });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();需要执行的代码 查看全部
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();需要执行的代码 查看全部
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();需要执行的代码
图片加载后执行的代码
DNN主题 • 舒正兴 发表了文章 • 0 个评论 • 554 次浏览 • 2020-12-29 14:53
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();需要执行的代码 查看全部
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();需要执行的代码 查看全部
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();需要执行的代码