.live()
**REMOVED**
JQ Home <<
Events <<
.live()
Attach event handlers.
Description
The .live()
method is used to henceforth, attach an event handler to all elements matching the current selector for the given event type(s).
- Starting with jQuery version 1.7 more flexible event delegation can be achieved by using the
.on()
and.off()
methods. The.on()
method allows us to attach event handlers directly to a document and is the preferred method to use when using this version onwards.
This method was deprecated in jQuery 1.7 and removed in jQuery 1.9 and we are just showing it for completeness.
- Use .on() instead.
Syntax
Signature | Description |
---|---|
.live( events, handler(eventObject) ) | Henceforth, attach an event handler to all elements matching the current selector for the given event type(s). |
.live( events, data, handler(eventObject) ) | Henceforth, attach an event handler to all elements matching the current selector for the given event type(s), passing an object of data. |
.live( eventTypes ) | Henceforth, attach an object of event type(s) and functions to all elements matching the current selector. |
Parameters
Parameter | Description | Type |
---|---|---|
events | A string containing one or more DOM event types or custom event names. | String |
handler(eventObject) | A function to execute when the event triggers. | Function |
eventTypes | An object of event type(s) and functions to execute for them. | PlainObject |
Return
A jQuery
object.
Related Tutorials
jQuery Advanced Tutorials - Lesson 4 - Event Handler Attachments