jQuery中live()使用报错,TypeError: $(...).live is not a function
来源:互联网 发布:湖北广电网络宽带登录 编辑:程序博客网 时间:2024/05/17 22:39
jquery中的live()方法在jquery1.9及以上的版本中已被废弃了,如果使用,会抛出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)
0 0
- jQuery中live()使用报错,TypeError: $(...).live is not a function
- jQuery中live()使用报错,TypeError: $(...).live is not a function(转)
- TypeError: a(...).live is not a function(jquery.unobtrusive-ajax.min.js 引入报错)
- 关于jquery使用live()方法的问题Uncaught TypeError: $(...).live is not a function
- jQuery 1.9 .live() is not a function
- $(...).live is not a function
- $(...).live is not a function
- 控制台出现 jQuery 1.9 .live() is not a function 解决方法
- jquery.js里面报错Uncaught TypeError: a.indexOf is not a function
- jquery提交表单报错 Uncaught TypeError: s[y] is not a function
- TypeError: jQuery(...).validationEngine is not a function
- jquery TypeError: $.widget is not a function
- js报错:TypeError: document.GetElementById is not a function
- js报错 :TypeError: yanzhengma is not a function
- js报错:TypeError: document.GetElementById is not a function
- ajaxfileupload.js结合低版本jquery报异常:TypeError: jQuery.handleError is not a function
- ecshop中使用Jquery特效报错“b.replace is not a function”
- TypeError: $ is not a function when calling jQuery function
- 阿里云服务器下LAMP环境配置--基于CentOS 6.3
- 阻塞非阻塞与同步异步的区别?
- macOS设置(显示/隐藏 )隐藏文件
- LeetCode:412. Fizz Buzz
- jsp 页面 按回车键 触发事件
- jQuery中live()使用报错,TypeError: $(...).live is not a function
- Android selinux权限设置
- Dagger2入门
- TCP长连接与短连接的区别
- 前端学习(5):javaScript权威指南第十章:cookie和其他客户存储技术
- HTTPS工作原理和TCP握手机制
- JavaScript学习总结(四)function函数部分
- sql数据类型有哪些
- php函数获取真实客户端IP地址