jQuery die 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>
  <head>
    <script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">
    <!--from   w  w  w  .j  a v a 2  s.c o m-->
        $(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>
  <head>
    <script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){<!--from   ww w  . j a va 2  s .co m-->
              $("div").die();
        });
    </script>
  </head>
  <body>
    <body>
       <div><h1>java2s.com</h1></div>
    </body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Tutorial »




Basics
Selector
DOM
Event
Effect
Utilities