首页 / JQUERY / jquery 事件绑定处理方式
jquery 事件绑定处理方式
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jquery 事件绑定处理方式,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2831字,纯文字阅读大概需要5分钟。
内容图文
![jquery 事件绑定处理方式](/upload/InfoBanner/zyjiaocheng/1317/f939f1a18df74623b0db3ef371a46488.jpg)
jquery 事件绑定的几种方式 ,click, blind,live,<SPAN style=‘font: 12px/18px "Microsoft YaHei", Verdana, Arial, Helvetica, sans-serif; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;‘>delegate,on
<SPAN style=‘font: 12px/18px "Microsoft YaHei", Verdana, Arial, Helvetica, sans-serif; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;‘>click 效率太慢 淘汰。
<SPAN style=‘font: 12px/18px "Microsoft YaHei", Verdana, Arial, Helvetica, sans-serif; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;‘>blind 没有动态绑定功能
<SPAN style=‘font: 12px/18px "Microsoft YaHei", Verdana, Arial, Helvetica, sans-serif; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;‘>live是把事件绑定到document 上 循环所有元素 通过冒泡 找到指定元素 执行事件处理,
$(‘table tr‘).live(‘click‘,function(){});
<SPAN style=‘font: 12px/18px "Microsoft YaHei", Verdana, Arial, Helvetica, sans-serif; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;‘>delegate 是把 事件绑定到指定的父元素上 这样循环元素范围缩小 效率高 ,
$(‘table‘).delegate(‘tr‘,‘click‘,function(){});
<SPAN style=‘font: 12px/18px "Microsoft YaHei", Verdana, Arial, Helvetica, sans-serif; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;‘>on 也包含了 delegate 的功能 ,on是1,.7版本以上支持的 事件绑定的统一方式,效率高 调用简单不用考虑 什么时间注册时间
$(‘table‘).on(‘click‘,‘tr‘,function(){});
原文:http://www.cnblogs.com/liulanghu/p/3620482.html
内容总结
以上是互联网集市为您收集整理的jquery 事件绑定处理方式全部内容,希望文章能够帮你解决jquery 事件绑定处理方式所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。