Home >>jQuery Tutorial >jQuery live() Method

jQuery live() Method

jQuery live() Method

jQuery live() method in jQuery is used to attaches one or multiple event handlers for selected elements which specifies a function to run when the events occur and will work for both current and FUTURE elements.

Syntax:
$(selector).live(event,data,function)

Parameter Values

Parameter Description
event It is a required parameter and is used to specifies one or multiple events to add to the elements
data It is optional parameter and is used to specifies additional data to pass along to the function
function It is a required parameter and is used to specifies the function to run when the event occurs
Here is an Example of jQuery live() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$(".btn1").live("click", function(){
$(".txt").slideToggle();
});
});
</script>
</head>
<body>
<p class="txt">This is phptpoint</p>
<button class="btn1">Click me!</button>
</body>
</html>

Output:

This is phptpoint


No Sidebar ads