我在这里和网上其他地方读过一些关于live()
和delegate()
之间差异的帖子.然而,我还没有找到我想要的答案(如果这是一个骗局,请告诉我).
I know that the difference between live
and delegate
is that live
cannot be used in a chain. I also read somewhere that delegate
is in some cases faster (better performance).
My question is, is there a situation where you should use live
instead of delegate
?
UPDATE个
我设置了一个simple test,以查看性能上的差异.
我还添加了jQuery1.7中提供的新.on()
+
结果很大程度上总结了答案中所述的性能问题.
- 除非jQuery版本不支持
.delegate()
,否则不要使用.live()
. - 除非jQuery版本不支持
.on()
,否则不要使用.delegate()
.
.live()
和.delegate()
之间的差别比delegate()
和.on()
之间的差别要大得多.