.die()
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>
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
<!-- w ww . ja va 2s. com-->
$(document).ready(function(){
$("div").die("click", function(event){
event.preventDefault();
});
});
</script>
</head>
<body>
<body>
<div><h1>java2s.com</h1></div>
</body>
</html>
The code above generates the following result.
Unbind all events
The following code unbinds all live events from all paragraphs.
<html>
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){<!--from w w w. j a v a 2 s . c om-->
$("div").die();
});
</script>
</head>
<body>
<body>
<div><h1>java2s.com</h1></div>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Event
Event
Event attributes
event.keycode
event.clientX/clientY
pageX/pageY
Cancel event
Event target
bind
.blur()
.change()
.click()
.error()
.dblclick()
.delegate()
.hover()
.keydown()
.keypress()
.keyup()
.live()
.load()
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseover()
.mouseout()
.mouseup()
.off()
.on()
.one()
.ready()
.resize()
.scroll()
.select()
.submit()
.toggle()
.trigger()
.triggerHandler()
.unbind()
.undelegate()
.unload()
Event
Event attributes
event.keycode
event.clientX/clientY
pageX/pageY
Cancel event
Event target
bind
.blur()
.change()
.click()
.error()
.dblclick()
.delegate()
.die()
.focus().hover()
.keydown()
.keypress()
.keyup()
.live()
.load()
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseover()
.mouseout()
.mouseup()
.off()
.on()
.one()
.ready()
.resize()
.scroll()
.select()
.submit()
.toggle()
.trigger()
.triggerHandler()
.unbind()
.undelegate()
.unload()