YouTip LogoYouTip

Event Live

## jQuery live() Method The `live()` method attaches one or more event handlers for selected elements and specifies a function to run when these events occur. Event handlers attached using the `live()` method work for both current elements and **future elements** matching the selector (such as new elements created dynamically by a script). > ⚠️ **Deprecation Notice:** > The `live()` method was **deprecated** in jQuery version 1.7 and **removed** in version 1.9. It has been replaced by the [on()](event-on.html) method. This guide is preserved for legacy codebase reference. To migrate legacy code, please refer to the (#modern-alternative-using-on) section below. --- ## Syntax ```javascript $(selector).live(event, data, function) ``` ### Parameter Values | Parameter | Type | Description | | :--- | :--- | :--- | | `event` | *String* | **Required.** Specifies one or more events to attach to the elements. Multiple event values can be separated by spaces (e.g., `"click dblclick"`). Must be a valid DOM event. | | `data` | *Object* | **Optional.** Specifies additional data to be passed to the event handler function. | | `function` | *Function* | **Required.** Specifies the function to run when the event occurs. | --- ## Code Examples ### Example 1: Basic Usage Toggle the visibility of `

` elements when a `

← Event LoadEvent Keyup β†’