{"id":186,"date":"2023-08-25T17:22:24","date_gmt":"2023-08-25T17:22:24","guid":{"rendered":"\/\/api.jquery.com\/?p=186"},"modified":"2025-04-14T17:10:35","modified_gmt":"2025-04-14T17:10:35","slug":"die","status":"publish","type":"post","link":"https:\/\/api.jquery.com\/die\/","title":{"rendered":".die()"},"content":{"rendered":"<article id=\"die1\" class=\"entry method\"><h2 class=\"section-title\">\n<span class=\"name\">.die()<\/span><span class=\"returns\">Returns: <a href=\"http:\/\/api.jquery.com\/Types\/#jQuery\">jQuery<\/a><\/span><span class=\"version-details\">version deprecated: <a href=\"\/category\/version\/1.7\/\">1.7<\/a>, removed: <a href=\"\/category\/version\/1.9\/\">1.9<\/a><\/span>\n<\/h2>\n<div class=\"entry-wrapper\">\n<p class=\"desc\"><strong>Description: <\/strong>Remove event handlers previously attached using <code>.live()<\/code> from the elements.<\/p>\n<ul class=\"signatures\">\n<li class=\"signature\">\n<h4 class=\"name\">\n<span class=\"version-details\">version added: <a href=\"\/category\/version\/1.4.1\/\">1.4.1<\/a><\/span><a id=\"die\" href=\"#die\"><span class=\"icon-link\"><\/span>.die()<\/a>\n<\/h4>\n<ul><li><div class=\"null-signature\">This signature does not accept any arguments.<\/div><\/li><\/ul>\n<\/li>\n<li class=\"signature\">\n<h4 class=\"name\">\n<span class=\"version-details\">version added: <a href=\"\/category\/version\/1.3\/\">1.3<\/a><\/span><a id=\"die-eventType-handler\" href=\"#die-eventType-handler\"><span class=\"icon-link\"><\/span>.die( eventType [, handler ] )<\/a>\n<\/h4>\n<ul>\n<li id=\"die-eventType-handler-eventType\">\n<div><strong>eventType<\/strong><\/div>\n<div>Type: <a href=\"http:\/\/api.jquery.com\/Types\/#String\">String<\/a>\n<\/div>\n<div>A string containing a JavaScript event type, such as <code>click<\/code> or <code>keydown<\/code>.<\/div>\n<\/li>\n<li id=\"die-eventType-handler-handler\">\n<div><strong>handler<\/strong><\/div>\n<div>Type: <a href=\"http:\/\/api.jquery.com\/Types\/#String\">String<\/a>\n<\/div>\n<div>The function that is no longer to be executed.<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"signature\">\n<h4 class=\"name\">\n<span class=\"version-details\">version added: <a href=\"\/category\/version\/1.4.3\/\">1.4.3<\/a><\/span><a id=\"die-events\" href=\"#die-events\"><span class=\"icon-link\"><\/span>.die( events )<\/a>\n<\/h4>\n<ul><li id=\"die-events-events\">\n<div><strong>events<\/strong><\/div>\n<div>Type: <a href=\"http:\/\/api.jquery.com\/Types\/#PlainObject\">PlainObject<\/a>\n<\/div>\n<div>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.<\/div>\n<\/li><\/ul>\n<\/li>\n<\/ul>\n<div class=\"longdesc\" id=\"entry-longdesc\">\n    <div class=\"warning\">\n      <p>Note: This API has been removed in jQuery 1.9; please use <a href=\"\/on\/\"><code>on()<\/code><\/a> instead.<\/p>\n    <\/div>\n    <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>.\n  See the discussions of <code>.live()<\/code> and <code>.off()<\/code> for further details.<\/p>\n    <p>If used without an argument, .die() removes <em>all<\/em> event handlers previously attached using <code>.live()<\/code> from the elements.<\/p>\n    <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>\n    <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>\n  <\/div>\n<section class=\"entry-examples\" id=\"entry-examples\"><header><h2>Examples:<\/h2><\/header><div class=\"entry-example\" id=\"example-0\">\n<h3>\n\t\t\t\tExample 1<\/h3>\n<p>To unbind all live events from all paragraphs, write:<\/p>\n<div class=\"syntaxhighlighter javascript\">\n\t<table>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td class=\"gutter\">\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n1\">1<\/div>\n\t\t\t\t\t\n\t\t\t\t<\/td>\n\t\t\t\t\n\t\t\t\t<td class=\"code\">\n\t\t\t\t\t<pre><div class=\"container\"><div class=\"line\"><code>$( <span class=\"hljs-string\">\"p\"<\/span> ).die();<\/code><\/div><\/div><\/pre>\n\t\t\t\t<\/td>\n\t\t\t<\/tr>\n\t\t<\/tbody>\n\t<\/table>\n<\/div>\n\n<\/div>\n<div class=\"entry-example\" id=\"example-1\">\n<h3>\n\t\t\t\tExample 2<\/h3>\n<p>To unbind all live click events from all paragraphs, write:<\/p>\n<div class=\"syntaxhighlighter javascript\">\n\t<table>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td class=\"gutter\">\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n1\">1<\/div>\n\t\t\t\t\t\n\t\t\t\t<\/td>\n\t\t\t\t\n\t\t\t\t<td class=\"code\">\n\t\t\t\t\t<pre><div class=\"container\"><div class=\"line\"><code>$( <span class=\"hljs-string\">\"p\"<\/span> ).die( <span class=\"hljs-string\">\"click\"<\/span> );<\/code><\/div><\/div><\/pre>\n\t\t\t\t<\/td>\n\t\t\t<\/tr>\n\t\t<\/tbody>\n\t<\/table>\n<\/div>\n\n<\/div>\n<div class=\"entry-example\" id=\"example-2\">\n<h3>\n\t\t\t\tExample 3<\/h3>\n<p>To unbind just one previously bound handler, pass the function in as the second argument:<\/p>\n<div class=\"syntaxhighlighter javascript\">\n\t<table>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td class=\"gutter\">\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n1\">1<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n2\">2<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n3\">3<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n4\">4<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n5\">5<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n6\">6<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n7\">7<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n8\">8<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n9\">9<\/div>\n\t\t\t\t\t\n\t\t\t\t<\/td>\n\t\t\t\t\n\t\t\t\t<td class=\"code\">\n\t\t\t\t\t<pre><div class=\"container\"><div class=\"line\"><code><span class=\"hljs-keyword\">var<\/span> foo = <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\"><\/span>) <\/span>{<\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>  <span class=\"hljs-comment\">\/\/ Code to handle some kind of event<\/span><\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>};<\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code> <\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code><span class=\"hljs-comment\">\/\/ Now foo will be called when paragraphs are clicked<\/span><\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>$( <span class=\"hljs-string\">\"p\"<\/span> ).live( <span class=\"hljs-string\">\"click\"<\/span>, foo );<\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code> <\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code><span class=\"hljs-comment\">\/\/ Now foo will no longer be called<\/span><\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>$( <span class=\"hljs-string\">\"p\"<\/span> ).die( <span class=\"hljs-string\">\"click\"<\/span>, foo );<\/code><\/div><\/div><\/pre>\n\t\t\t\t<\/td>\n\t\t\t<\/tr>\n\t\t<\/tbody>\n\t<\/table>\n<\/div>\n\n<\/div><\/section>\n<\/div><\/article>","protected":false},"excerpt":{"rendered":"<p>Remove event handlers previously attached using .live() from the elements.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,34,61,87,89,91],"tags":[],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-deprecated-17","category-event-handler-attachment","category-removed","category-87","category-89","category-91"],"_links":{"self":[{"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":3,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":1339,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/posts\/186\/revisions\/1339"}],"wp:attachment":[{"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}