Home >>jQuery Tutorial >jQuery event.namespace Property

jQuery event.namespace Property

jQuery event.namespace Property

jQuery event.namespace property in jQuery is used to returns the custom namespace when the event was triggered.

Syntax:
event.namespace

Parameter Values

Parameter Description
event It is a required parameter and is used to the event parameter comes from the event binding function
Here is an Example of jQuery event.namespace Property:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".txt1").on("custom.someNamespace",function(event){
alert(event.namespace);
});
$(".txt1").click(function(event){
$(this).trigger("custom.someNamespace");
});  
$(".btn1").click(function(){
$(".txt1").off("custom.someNamespace");
});
});  
</script>
</head>
<body>
<p class="txt1">Click me !!</p>
<button class="btn1">Remove namespace</button>
</body>
</html>

Output:

Click me !!