.die()

In this chapter you will learn:

  1. Syntax and Description for .die() event
  2. How to unbind all event

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>

Click to view the demo

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>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. Syntax and Description for .focus() event
  2. How to set focus to text box
  3. How to fire focus event
  4. How to set value in case of focus event
Home » jQuery » Event
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()