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

前端之家收集整理的这篇文章主要介绍了jQuery 3.0 $(window).load(function(){});前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以jQuery 3.0今天发布了,由于某种原因,以下代码不再适用于我的网站:
$(window).load(function() {});

任何人都可以建议我如何解决这个问题或者当/ every /加载时激活的替代方案?

解决方法

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) {})
原文链接:https://www.f2er.com/jquery/181593.html

猜你在找的jQuery相关文章