惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
GbyAI
GbyAI
WordPress大学
WordPress大学
月光博客
月光博客
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google DeepMind News
Google DeepMind News
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
博客园 - 司徒正美
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
Blog — PlanetScale
Blog — PlanetScale
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
L
LangChain Blog
腾讯CDC
T
The Blog of Author Tim Ferriss
量子位

博客园 - 沙加

前端设计模式之 MPVC Part 3 前端设计模式之 MPVC Part 2 前端设计模式之 MPVC Part 1 App Engine 缓存与数据一致性 常用跨浏览器效果 同步请求真的有那么恐怖? Google Closure 的单元测试纪要 双飞翼布局的选区问题 一个 JS 面试题目 HTML 5 之旅 part 1 - 无头苍蝇 Objective-C 学习笔记 - part 12 - 多线程 Objective-C 学习笔记 - part 11 - 错误处理 Objective-C 学习笔记 - part 10 - 选择器 Objective-C 学习笔记 - part 9 - 静态标记的类型 Objective-C 学习笔记 - part 8 - 快速枚举 Objective-C 学习笔记 - part 7 - 相关引用 Objective-C 学习笔记 - part 6 - 类别与扩展 Objective-C 学习笔记 - part 5 - 申明属性 Objective-C 学习笔记 - part 4 - 协议
bind, delegate, live 三者的区别
沙加 · 2011-08-22 · via 博客园 - 沙加

简单总结如下:

  • bind 直接绑定 handler 于元素上
  • delegate 绑定事件在父级元素上
  • live 绑定于 document 之上

为啥有了 bind 还需要 delegate ?

使用 deletegate 不需要为每一个元素都绑定事件处理器,并能处理动态创建的元素的 dom 事件。

为啥 delegate 优于 live?

它只作用于靠近目标目标元素的父级元素上,不需要冒泡到 document,在需要的时候可以停止冒泡事件;live 需要绑定于特定的 css 选择器,而 delegate 不需要,灵活性更高。

为啥还要用 live?

一般用于作用广泛的全站事件,比如 hovercard。