diff --git a/categories.xml b/categories.xml index 55038248..f2ee15fa 100644 --- a/categories.xml +++ b/categories.xml @@ -66,6 +66,11 @@
For more information, see the Release Notes/Changelog at https://blog.jquery.com/2013/05/24/jquery-1-10-0-and-2-0-1-released/
]]> +As of jQuery 1.7, the .on()
method is the preferred method for attaching event handlers to a document. For earlier versions, the .bind()
method is used for attaching an event handler directly to elements. Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to .bind()
occurs. For more flexible event binding, see the discussion of event delegation in .on()
or .delegate()
.
As of jQuery 3.0, .bind()
has been deprecated. It was superseded by the .on()
method for attaching event handlers to a document since jQuery 1.7, so its use was already discouraged. For earlier versions, the .bind()
method is used for attaching an event handler directly to elements. Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to .bind()
occurs. For more flexible event binding, see the discussion of event delegation in .on()
or .delegate()
.
Any string is legal for eventType
; if the string is not the name of a native DOM event, then the handler is bound to a custom event. These events are never called by the browser, but may be triggered manually from other JavaScript code using .trigger()
or .triggerHandler()
.
If the eventType
string contains a period (.
) character, then the event is namespaced. The period character separates the event from its namespace. For example, in the call .bind( "click.name", handler )
, the string click
is the event type, and the string name
is the namespace. Namespacing allows us to unbind or trigger some events of a type without affecting others. See the discussion of .unbind()
for more information.
There are shorthand methods for some standard browser events such as .click()
that can be used to attach or trigger event handlers. For a complete list of shorthand methods, see the events category.
As of jQuery 1.7, .delegate()
has been superseded by the .on() method. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on() method. In general, these are the equivalent templates for the two methods:
As of jQuery 3.0, .delegate()
has been deprecated. It was superseded by the .on()
method since jQuery 1.7, so its use was already discouraged. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on()
method. In general, these are the equivalent templates for the two methods:
// jQuery 1.4.3+
$( elements ).delegate( selector, events, data, handler );
@@ -148,4 +148,5 @@ $( "button" ).click(function() {
+
Event handlers attached with .bind()
can be removed with .unbind()
. (As of jQuery 1.7, the .on()
and .off()
methods are preferred to attach and remove event handlers on elements.) In the simplest case, with no arguments, .unbind()
removes all handlers attached to the elements:
As of jQuery 3.0, .unbind()
has been deprecated. It was superseded by the .off()
method since jQuery 1.7, so its use was already discouraged.
Event handlers attached with .bind()
can be removed with .unbind()
. In the simplest case, with no arguments, .unbind()
removes all handlers attached to the elements:
$( "#foo" ).unbind();
@@ -155,4 +156,5 @@ $( "p" ).unbind( "click", foo ); // ... foo will no longer be called.
The .undelegate()
method is a way of removing event handlers that have been bound using .delegate()
. As of jQuery 1.7, the .on()
and .off()
methods are preferred for attaching and removing event handlers.
As of jQuery 3.0, .undelegate()
has been deprecated. It was superseded by the .off()
method since jQuery 1.7, so its use was already discouraged.
The .undelegate()
method is a way of removing event handlers that have been bound using .delegate()
.