.die()    ** REMOVED **S2C Home « Events « .die()

Remove event handlers.

Description

The .die() method is used to remove event handlers from elements that were previously attached using the .live() method.

  • Without any parameters the .die() method unattaches all event handlers previously attached using the .live() method.
  • For the .die() method to function correctly the selector used must exactly match the selector used when attaching the handlers using the .live() method.
  • Starting with jQuery version 1.7 more flexible event delegation can be achieved by using the .on() and .off() methods. The .on() method allows us to attach event handlers directly to a document and is the preferred method to use when using this version onwards.

This method was deprecated in jQuery 1.7 and removed in jQuery 1.9 and we are just showing it for completeness.

  • Use .on() instead.

Syntax

Signature Description
.die()Remove all handlers attached with the .live() method.
.die( eventType [, handler] )Remove an event handler previously attached using the .live() method from the elements.
.die( eventTypes )A map of event type(s) and previously bound functions attached with the .live() method to unattach from.

Parameters

Parameter Description Type
eventTypeA string containing one or more DOM event types or custom event names.
  • If the string used for eventType is not the name of a native DOM event, the handler is bound to a custom event. Custom events are never called by the browser, but can be triggered manually from other JavaScript code using the .trigger() or .triggerHandler() methods.
  • If a period (.) character is present anywhere in the eventType string, then that event becomes namespaced. The characters before the period (.) character represent the eventType, whilst the characters after the period (.) character represent the namespace. As an example .delegate('anEventType.aNamespace', handler) could be used to handle some events whilst not affecting events for .delegate('anEventType.aNamespace2', handler). In essence, namespacing allows us to action certain events for an eventType without affecting other events for that eventType.
String
handlerA function to unattach from.Function
eventTypesAn object of event type(s) and previously bound functions to unattach from.Object

Return

A jQuery object.