今天发布了 jQuery 3.0,由于某种原因,以下代码不再在我的网站上运行:
$(window).load(function() {});
任何人都可以建议我如何修复此问题或在加载/everything/时激活的替代方案吗?
最佳答案
阅读自breaking-change-load-unload-and-error-removed :
Breaking change: .load(), .unload(), and .error() removed
These methods are shortcuts for event operations, but had several API limitations. The event .load() method conflicted with the ajax .load() method. The .error() method could not be used with window.onerror because of the way the DOM method is defined. If you need to attach events by these names, use the .on() method, e.g. change $("img").load(fn) to $(img).on("load", fn).
因此,您需要更改:
$(window).load(function() {});
至:
$(window).on("load", function (e) {})
关于jQuery 3.0 $(window).load(function(){});,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37751179/