.die()
In this chapter you will learn:
Syntax and Description
.die(eventType[, handler])
eventType
is a string containing a JavaScript event type such as click or keydown.
handler (optional)
is the function that is to be no longer executed.
Return value is the jQuery object, for chaining purposes.
jQuery .die()
Remove an event handler previously attached
using .live()
from the elements.
Any handler that has been attached with .live()
can be removed with
.die()
.
The following code removes click event from div tag.
<html><!--from java2s . c o m-->
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").die("click", function(event){
event.preventDefault();
});
});
</script>
</head>
<body>
<body>
<div><h1>java2s.com</h1></div>
</body>
</html>
Unbind all events
The following code unbinds all live events from all paragraphs.
<html><!-- j a v a 2 s .c o m-->
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").die();
});
</script>
</head>
<body>
<body>
<div><h1>java2s.com</h1></div>
</body>
</html>
Next chapter...
What you will learn in the next chapter:
- Syntax and Description for .focus() event
- How to set focus to text box
- How to fire focus event
- How to set value in case of focus event