微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/jquery/181593.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐