How to use undelegate() Method Event in JQuery
This article describe about undelegate() Method Event in jQuery.
undelegate() Method Event in jQuery
With the delegate() method add one or more event handler remove by the undelegate() method.
Syntax
$(selector).undelegate(selector,event,function)
|
Parameter |
Description |
selector |
Optional. Define selector to remove event handler |
event |
Optional. Define one or more type event handler to remove from. |
function |
Optional. Define specific event handler to remove. |
Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("body").delegate("p", "click", function () {
$(this).slideToggle();
});
$("button").click(function () {
$("body").undelegate();
});
});
</script>
</head>
<body>
<p>This is me first paragraph.</p>
<p>This is second paragraph.</p>
<p>Click on ane paragraph p element to make it disappear. Including this one also.</p>
<button>Remove event handlers, added with the delegate() method, from all elements</button>
</body>
</html>
|
Output
You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here