jQuery event.namespace property
Example
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");
});
Try it »
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 starting with an underscore are reserved.
Syntax
event
.namespace
| Parameters | Description |
|---|---|
| event | Required.event The parameters come from the event binding function. |
More examples
Remove a custom namespace from a specific click event
Remove a custom namespace from a specific click event without removing any other click event handlers.
jQuery event methods