How does jQuery .live() work?

后端 未结 5 606
渐次进展
渐次进展 2020-12-03 22:25

I was thinking about performance regarding

.click() vs .live(\"click\")

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

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 22:41

    From the jQuery manual on .live():

    The .live() method is able to affect elements that have not yet been added to the DOM through the use of event delegation: a handler bound to an ancestor element is responsible for events that are triggered on its descendants. The handler passed to .live() is never bound to an element; instead, .live() binds a special handler to the root of the DOM tree.

    As you see, there is no timer involved.

提交回复
热议问题