[英]Execute JS once all images are loaded?
Below is my js class. 下面是我的js类。
I need it to execute once all images are loaded, I understand I need to do this via: 我需要它在所有图像加载后执行,我知道我需要通过以下方法执行:
$(window).load
But how would I incorporate this into my class? 但是我如何将其纳入班级呢?
this.mc = this.mc || {};
(function () {
"use strict";
var MyClass = function () {
this.init();
};
p.init = function () {
// Init
this.ready();
};
mc.MyClass = MyClass;
}(window));
var myClass;
$(function () {
myClass = new mc.MyClass();
});
Replace 更换
$(function () {
myClass = new mc.MyClass();
});
with 与
$(window).on('load', function() {
myClass = new mc.MyClass();
});
I'm not quite sure if I get you.. but 我不太确定是否能找到你。
window.onload = function() {
myClass = new mc.MyClass();
};
should do. 应该做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.