jquery3.0移除了.load()方法

参考链接:新版jquery去掉load事件了吗?

今天也遇到了这个问题,查了一下文档,确实从3.0开始移除了load、unload、error事件方法。不过依然可以用on方法绑定这些事件。

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).

就是说以前直接$(obj).load(),现在被改为$(obj).on('load',fn)了,好吧~

posted @ 2018-01-23 10:00  jiafeng  阅读(462)  评论(0编辑  收藏  举报