jQuery event.namespaceProperty

jQuery 事件方法jQuery Event Methods

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");
});

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.


实例s

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.


jQuery 事件方法jQuery Event Methods

Other Extensions