Did you find this useful?
Socialize it today.

jQuery Live Event

Sunday, July 01, 2012

The jQuery live event is used to attach one or more event handlers for selected elements. It also specifies a function to run when the event is triggered. Event handlers attached using the live() method will work for both current and future elements matching the selector.



eventOne or more events to attach. Event values are separated by space
dataAdditional optional data to pass along to the function
functionOptional function to run when the event(s) occur

Basic Example

In the following jQuery example, the live() method adds the click event to the element with an id of "imgMouse". When the "imgMouse" element is clicked, the "click" event is executed through the live method. In this example, the div element will be shown or hidden as the mouse icon is clicked. Try it yourself, by clicking the mouse icon.

<div id="divParent">
    <img id="imgMouse"src="#" />
    <div id="divChild">
    <div id="divText">Click the mouse icon to toggle ....

$("#imgMouse").live("click", function () {

Click the mouse icon to toggle this display.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.

Recommended Books & Training Resources

Pro jQuery HTML CSS and JavaScript Editor JavaScript and jQuery: The Missing Manual