jQuery event.namespaceProperty
Examples
Add and remove a custom namespace:
$("p").on("custom.someNamespace",function(event){
alert(event.namespace);
});
$("p").click(function(event){
$(this).trigger("custom.someNamespace");
});
$("button").click(function(){
$("p").off("custom.someNamespace");
});
alert(event.namespace);
});
$("p").click(function(event){
$(this).trigger("custom.someNamespace");
});
$("button").click(function(){
$("p").off("custom.someNamespace");
});
Try it yourself »
Definition and Usage
When an event is triggered, the event.namespace property returns the custom namespace.
This property can be used by plugin authors to handle tasks differently depending on the namespace used.
Tip:For jQuery, namespaces beginning with an underscore are reserved.
Syntax
event.namespace
| Parameters | Description |
|---|---|
| event | Required.eventThe parameter comes from the event binding function. |
More Examples
Remove a custom namespace for a specific click event
Remove the custom namespace for a specific click event without removing any other click event handlers.
Other Extensions
jQuery Event Methods