jQuery中live()使用报错,TypeError: $(...).live is not a function
2017-03-02 16:01
615 查看
TypeError: $(...).live is not a function错误。
解决方法:
之前的用法:
.live(events, function)
新方法:
.on(eventType, selector, function)
若selector不需要,可传入null
例子1:
之前:
$('#mainmenu a').live('click', function)
之后:
$('#mainmenu').on('click', 'a', function)
例子2:
之前:
$('.myButton').live('click', function)
之后(应使用距离myButton最近的节点):
$('#parentElement').on('click', ‘.myButton’, function)
若不知最近的节点,可使用如下的方法:
$('body').on('click', ‘.myButton’, function)
相关文章推荐
- jQuery中live()使用报错,TypeError: $(...).live is not a function(转)
- 关于jquery使用live()方法的问题Uncaught TypeError: $(...).live is not a function
- 使用jquery插件autocomplete时候出现typeerror:this.source is not a function即与jquery的autocomplete冲突
- jquery版本更新后无live函数的处理.TypeError: $(...).live is not a function
- TypeError: a(...).live is not a function(jquery.unobtrusive-ajax.min.js 引入报错)
- jQuery.Deferred exception: a.indexOf is not a function TypeError: a.indexOf is not a function
- 使用vue时Module build failed: TypeError: this._init is not a function错误的解决方法
- Jquery报错:Uncaught TypeError: ((m.event.special[e.origType] || (intermediate value)).handle || e.handler).apply is not a function
- TypeError: jQuery.easing[this.easing] is not a function
- jQuery 关于 Uncaught TypeError: XXX is not a function
- jquery中Uncaught TypeError: $(...).ajaxUpload is not a function(…)错误解决方法
- jquery TypeError: 'undefined' is not a function (evaluating 'elem.nodeName.toLowerCase()') [jquery.js:1904]错误原因
- jquery TypeError: $.widget is not a function
- JQuery中button提交表单报TypeError: elem[type] is not a function jquery
- vue项目使用手机浏览器访问时报错:Uncaught TypeError: Object.assign is not a function
- TypeError: $(...).dataTable is not a function 或 jQuery is not defined
- jquery提交表单报错 Uncaught TypeError: s[y] is not a function
- jquery TypeError: U[a].exec is not a function 是咋个回事
- Uncaught TypeError: $(...).Validform is not a function 如何解决,以及其他方式替换jquery功能
- jQuery 异常 Uncaught TypeError: url.indexOf is not a function