jQuery .live()如何工作? [英] How does jQuery .live() work?

查看:100
本文介绍了jQuery .live()如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑性能方面的问题

I was thinking about performance regarding

.click().live("click")

这使我想知道.live的工作原理.

and that left me wondering about how .live does work.

它是否监视DOM的变化,并且当它检测到DOM的变化时,它仅附加事件,然后使用某种计时器(我认为不是,但是如果这样做非常重要,则计时器会我一个可悲的人)

Does it monitor DOM changes and when it detects a change in the DOM it just attaches the event then, does it use some sort of timer (I wouldn't think so, but if it did this is very important, timers make me a sad person)

推荐答案

liveclick事件绑定到DOM的document元素.随着浏览器事件在DOM树中冒出气泡,所有匹配的元素都会触发click事件.

live binds the click event to the DOM's document element. As browser events bubble up through the DOM tree, the click event is triggered for any matching elements.

这是一篇很好的文章,对所有内容进行了解释.

Here's a good article explaining it all.

http://www.alfajango .com/blog/the-difference-between-jquerys-bind-live-and-delegate/

这篇关于jQuery .live()如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆