jQuery live() Method

jQuery live() method is used to attaches one or more event handlers for selected elements, and when live event occurs specified function execute.

The live() method was deprecated in jQuery 1.7. and removed om jQuery 1.9.

Syntax

This syntax represent to the live() method

$(selector).live(eventType, data, function);
Parameter Type Description
eventType String Required. Specifies one or more DOM event types (such as "click" or "dblclick" or custom event names) to attach to the elements
data Object Optional. Specifies additional data that will be passed to the event handler.
function Function Optional. Specifies the function to execute when the event is occurs

Example

This example represent the live event, it will attaches one or more event handlers on the selected elements.

<!DOCTYPE html>
<html>
<head>
  <title>jQuery live() method</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
  <script>
    $(document).ready(function(){
      $("p").live("click", function(){
        alert("clicked");
      });
    });
  </script>
</head>
<body>
    <p>Click or hover on below text it will trigger live() method</p> 
    <p style="border: 1px solid #000;">first paragraph text</p>
</body> 
</html>

Run it...   »