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

查看:85
本文介绍了jQuery 3.0 $(window).load(function(){});的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此jQuery 3.0于今天发布,由于某种原因,以下代码不再在我的网站上起作用:

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

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

有人能建议我如何解决此问题,或在加载/everything/时激活的替代方案吗?

Can anyone suggest how I fix this or an alternative that actives when /everything/ is loaded?

推荐答案

重大更改:.load()、. unload()和.error()已删除

Breaking change: .load(), .unload(), and .error() removed

这些方法是事件操作的快捷方式,但是有一些API限制.事件.load()方法与ajax .load()方法冲突.由于DOM方法的定义方式,.error()方法不能与window.onerror一起使用.如果您需要使用这些名称附加事件,请使用.on()方法,例如将$("img").load(fn)更改为$(img).on("load",fn).

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(){});的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆