jQuery3.0+报错Uncaught TypeError: e.indexOf is not a function

jQuery3.0+报错Uncaught TypeError: e.indexOf is not a function

使用.load()绑定事件时报错,Uncaught TypeError: e.indexOf is not a function

显示出错的代码为$('#id').load(function () {}

因为 .load() 在 jQuery1.8 时不建议使用,在 jQuery3.0 时弃用

使用 $('#id').on('load', function() {}) 代替即可


同时在3.0+被弃用的还有:

.error() :使用.on( "error", handle)代替

.unload() :使用.on( "unload", handle)代替


在3.0+不建议使用的有:

.bind().unbind().delegate().undelegate()

使用 .on().off() 代替