forked from jquery/api.jquery.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdie.xml
65 lines (63 loc) · 2.92 KB
/
die.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?xml version="1.0"?>
<entry type="method" name="die" return="jQuery" deprecated="1.7" removed="1.9">
<title>.die()</title>
<desc>Remove event handlers previously attached using <code>.live()</code> from the elements.</desc>
<signature>
<added>1.4.1</added>
</signature>
<signature>
<added>1.3</added>
<argument name="eventType" type="String">
<desc>A string containing a JavaScript event type, such as <code>click</code> or <code>keydown</code>.</desc>
</argument>
<argument name="handler" optional="true" type="String">
<desc>The function that is no longer to be executed.</desc>
</argument>
</signature>
<signature>
<added>1.4.3</added>
<argument name="events" type="PlainObject">
<desc>A plain object of one or more event types, such as <code>click</code> or <code>keydown</code> and their corresponding functions that are no longer to be executed.</desc>
</argument>
</signature>
<longdesc>
<div class="warning">
<p>Note: This API has been removed in jQuery 1.9; please use <a href="/on/"><code>on()</code></a> instead.</p>
</div>
<p>Any handler that has been attached with <code>.live()</code> can be removed with <code>.die()</code>. This method is analogous to calling <code>.off()</code> with no arguments, which is used to remove all handlers attached with <code>.on()</code>.
See the discussions of <code>.live()</code> and <code>.off()</code> for further details.</p>
<p>If used without an argument, .die() removes <em>all</em> event handlers previously attached using <code>.live()</code> from the elements.</p>
<p><strong>As of jQuery 1.7</strong>, use of <code>.die()</code> (and its complementary method, <code>.live()</code>) is not recommended. Instead, use <a href="/off/"><code>.off()</code></a> to remove event handlers bound with <a href="/on/"><code>.on()</code></a></p>
<p><strong>Note:</strong> In order for .die() to function correctly, the selector used with it must match exactly the selector initially used with .live().</p>
</longdesc>
<example>
<desc>To unbind all live events from all paragraphs, write:</desc>
<code><![CDATA[
$( "p" ).die();
]]></code>
</example>
<example>
<desc>To unbind all live click events from all paragraphs, write:</desc>
<code><![CDATA[
$( "p" ).die( "click" );
]]></code>
</example>
<example>
<desc>To unbind just one previously bound handler, pass the function in as the second argument:</desc>
<code><![CDATA[
var foo = function() {
// Code to handle some kind of event
};
// Now foo will be called when paragraphs are clicked
$( "p" ).live( "click", foo );
// Now foo will no longer be called
$( "p" ).die( "click", foo );
]]></code>
</example>
<category slug="events/event-handler-attachment"/>
<category slug="version/1.3"/>
<category slug="version/1.4.1"/>
<category slug="version/1.4.3"/>
<category slug="deprecated/deprecated-1.7"/>
<category slug="removed"/>
</entry>