2010-09-16 17:13:38 +00:00
<!DOCTYPE html>
2010-11-02 01:46:29 +00:00
< html lang = 'en' > < head >
2011-02-18 20:00:18 +00:00
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, minimum-scale=1, maximum-scale=1" > < meta http-equiv = 'content-type' content = 'text/html; charset=UTF-8' / > < / head > < body >
2010-09-18 16:20:35 +00:00
< div data-role = "page" >
2010-09-21 14:58:54 +00:00
< div data-role = "header" >
2010-09-16 17:13:38 +00:00
< h1 > .die()< / h1 >
< / div >
2010-09-16 18:27:10 +00:00
2010-10-12 19:50:28 +00:00
< div data-role = "content" data-theme = "c" id = "die1" >
2010-09-16 17:13:38 +00:00
< h2 class = "jq-clearfix roundTop section-title" >
< span class = "name" > .die()< / span > < span class = "returns" > Returns: < a class = "return" href = "http://docs.jquery.com/Types#jQuery" > jQuery< / a > < / span >
< / h2 >
< div class = " entry-details" >
< p class = "desc" > < strong > Description: < / strong > Remove all event handlers previously attached using .live() from the elements.< / p >
< ul class = "signatures" > < li class = "signature" id = "die" > < h4 class = "name" >
< span class = "versionAdded" > version added: < a href = "/category/version/1.4.1/" > 1.4.1< / a > < / span > .die()< / h4 > < / li > < / ul >
< div class = "longdesc" > < 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 > .unbind()< / code > with no arguments, which is used to remove all handlers attached with < code > .bind()< / code > .
See the discussions of < code > .live()< / code > and < code > .unbind()< / code > for further details.< / p > < / div >
< / div >
< / div >
2010-10-12 19:50:28 +00:00
< div data-role = "content" data-theme = "c" id = "die2" >
2010-09-16 17:13:38 +00:00
< h2 class = "jq-clearfix roundTop section-title" >
< span class = "name" > .die( eventType, [ handler ] )< / span > < span class = "returns" > Returns: < a class = "return" href = "http://docs.jquery.com/Types#jQuery" > jQuery< / a > < / span >
< / h2 >
< div class = " entry-details" >
< p class = "desc" > < strong > Description: < / strong > Remove an event handler previously attached using .live() from the elements.< / p >
< ul class = "signatures" > < li class = "signature" id = "die-eventType-handler" >
< h4 class = "name" >
< span class = "versionAdded" > version added: < a href = "/category/version/1.3/" > 1.3< / a > < / span > .die( eventType, [ handler ] )< / h4 >
< p class = "arguement" > < strong > eventType< / strong > A string containing a JavaScript event type, such as < code > click< / code > or < code > keydown< / code > .< / p >
< p class = "arguement" > < strong > handler< / strong > The function that is to be no longer executed.< / p >
< / li > < / ul >
< div class = "longdesc" > < p > Any handler that has been attached with < code > .live()< / code > can be removed with < code > .die()< / code > . This method is analogous to < code > .unbind()< / code > , which is used to remove handlers attached with < code > .bind()< / code > .
See the discussions of < code > .live()< / code > and < code > .unbind()< / code > for further details.< / p > < / div >
< h3 > Examples:< / h3 >
< div id = "entry-examples" class = "entry-examples" >
< div id = "example-0" >
< h4 > Example: < span class = "desc" > Can bind and unbind events to the colored button.< / span >
< / h4 >
< pre > < code class = "example demo-code" > < !DOCTYPE html>
< html>
< head>
< style>
button { margin:5px; }
button#theone { color:red; background:yellow; }
< /style>
< script src="http://code.jquery.com/jquery-latest.js"> < /script>
< /head>
< body>
< button id="theone"> Does nothing...< /button>
< button id="bind"> Bind Click< /button>
< button id="unbind"> Unbind Click< /button>
< div style="display:none;"> Click!< /div>
< script>
function aClick() {
$("div").show().fadeOut("slow");
}
$("#bind").click(function () {
$("#theone").live("click", aClick)
.text("Can Click!");
});
$("#unbind").click(function () {
$("#theone").die("click", aClick)
.text("Does nothing...");
});
< /script>
< /body>
< /html> < / code > < / pre >
< h4 > Demo:< / h4 >
< div class = "demo code-demo" > < / div >
< / div >
< div id = "example-1" >
< h4 > Example: < span class = "desc" > To unbind all live events from all paragraphs, write:< / span >
< / h4 >
< pre > < code class = "example" > $("p").die()< / code > < / pre >
< / div >
< div id = "example-2" >
< h4 > Example: < span class = "desc" > To unbind all live click events from all paragraphs, write:< / span >
< / h4 >
< pre > < code class = "example" > $("p").die( "click" )< / code > < / pre >
< / div >
< div id = "example-3" >
< h4 > Example: < span class = "desc" > To unbind just one previously bound handler, pass the function in as the second argument:< / span >
< / h4 >
< pre > < code class = "example" > var foo = function () {
// code to handle some kind of event
};
$("p").live("click", foo); // ... now foo will be called when paragraphs are clicked ...
$("p").die("click", foo); // ... foo will no longer be called.< / code > < / pre >
< / div >
< / div >
< / div >
< / div >
< / div >
< / body > < / html >