jQueryevent.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");
});
定義と使用法
event.namespaceプロパティは、イベントがトリガーされたときにカスタム名前空間を返します。
このプロパティは、プラグインの作成者が使用する名前空間に応じて異なる方法でタスクを処理するために使用できます。
ヒント:アンダースコアで始まる名前空間はjQuery用に予約されています。
構文
event.namespace
Parameter | Description |
---|---|
event | Required. The event parameter comes from the event binding function |
自分で試してみてください-例
のカスタム名前空間を削除する他のクリックイベントハンドラーを削除せずに、特定のクリックイベントのカスタム名前空間を削除します。