JQuery 3.0 $ (window) .load (function () {});

so jQuery 3.0 was released today, and for some reason, the following code no longer works on my site:

$(window).load(function() {}); 

Can anyone suggest how I fix this or the alternative that assets at boot / all /?

+18
jquery
Jun 10 '16 at 14:47
source share
1 answer

Reading from breaking-change-load-unload-and-error-removed :

Change violation: .load () ,. unload () and .error () removed

These methods are shortcuts for event operations, but have several API limitations. The eventload () method contradicted the ajax.load () method. The .error () method cannot be used with window.onerror because of the way the DOM method is defined. If you need to attach events with these names, use the .on () method, for example. change $ ("img"). load (fn) on $ (img) .on ("load", fn).

Therefore you need to change:

 $(window).load(function() {}); 

at

$ (window) .on ("load", function (e) {})

+49
Jun 10 '16 at 2:59
source share



All Articles