event.namespace


event.namespaceReturns: String

Description: The namespace specified when the event was triggered.

  • version added: 1.4.3event.namespace

This will likely be used primarily by plugin authors who wish to handle tasks differently depending on the event namespace used.

Example:

Determine the event namespace used.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>event.namespace demo</title>
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
</head>
<body>
<button>display event.namespace</button>
<p></p>
<script>
$( "p" ).on( "test.something", function( event ) {
alert( event.namespace );
});
$( "button" ).on( "click", function( event ) {
$( "p" ).trigger( "test.something" );
});
</script>
</body>
</html>

Demo: