event.namespace is a String on the jQuery event object. It holds the namespace from a namespaced bind or trigger (for example click.myPlugin → "myPlugin"). Added in jQuery 1.4.3. Mostly used by plugin authors to behave differently per namespace.
Remember
event.namespace // String — read-only
.on("click.myPlugin", fn) → namespace = "myPlugin"
.on("test.something", fn) → namespace = "something"
.on("click", fn) → namespace = ""
event.type → base name ("click", "test")
.off(".myPlugin") → remove all handlers in that namespace
Bind with a dotted name, then read the suffix inside the handler.
Pick a short namespace for your plugin or feature (for example myPlugin).
Bind with .on("click.myPlugin", handler) (or any event type).
Inside the handler, read event.namespace — and event.type for the base name.
To tear down plugin listeners only, call .off(".myPlugin").
To fire a namespaced custom event, use .trigger("test.something").
Piece
Required?
Role
Bind / trigger string
Yes
type or type.namespace
event.namespace
—
Suffix after the first dot (or "")
event.type
—
Base event name only
.off(".namespace")
Optional
Remove all handlers in that namespace
Pseudocode
Pseudocode
bindString = "type.namespace" // or just "type"
element.on(bindString, handler)
when event fires:
event.type = "type"
event.namespace = "namespace" // or "" if none
call handler(event)
// Plugin cleanup:
element.off(".namespace") // drops every handler with that suffix
Reference
Cheat Sheet
Keep these facts handy while wiring namespaced handlers.
Topic
Detail
Type
String property (not a method)
Since
jQuery 1.4.3
Official demo
test.something → "something"
No namespace
Empty string ""
Multi-segment
click.foo.bar → "foo.bar"
vs event.type
Type = base; namespace = suffix
Cleanup
.off(".myPlugin")
Mutates?
No — read-only; set by jQuery
Try it
Live Preview
Trigger namespaced custom events and see event.type + event.namespace — same idea as the official jQuery API demo.
Bound with namespaced .on() — Fire event to read event.namespace.
Result
Waiting — pick a trigger and click Fire event.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Official Demo: Read the Namespace
Bind test.something, trigger it from a button, show event.namespace.
jQuery
$("#target").on("test.something", function (event) {
$("#out").text('event.namespace = "' + event.namespace + '"');
});
$("#fire").on("click", function () {
$("#target").trigger("test.something");
});
Custom type.widget is not a DOM event — jQuery still supports it.
Suffix.refresh / destroy land in event.namespace.
Trigger. Buttons call .trigger("widget.refresh") or .trigger("widget.destroy").
Message. The handler rebuilds the full name from type + namespace.
Edge Cases & Pitfalls
Watch for these when using namespaced events.
empty
No namespace → "", not undefined
Plain binds leave event.namespace as an empty string. Prefer if (event.namespace) or an exact string compare.
split
Do not confuse type and namespace
For click.myPlugin, event.type is "click" and event.namespace is "myPlugin". Neither property holds the full "click.myPlugin" string.
off
.off("click") vs .off(".myPlugin")
.off("click") removes all click handlers. .off(".myPlugin") removes every event type under that namespace — safer for plugin teardown.
readonly
You cannot assign event.namespace
jQuery sets it from the bind/trigger string. To control it, bind or trigger with the dotted name you want.
Compatibility
Browser Support
event.namespace is a jQuery event-object property (since 1.4.3). It works in every browser where your loaded jQuery version runs — namespaces are a jQuery feature, not a native DOM API.
✓ Stable · jQuery 1.4.3+
event.namespace
Supported wherever jQuery 1.4.3+ is loaded. Prefer jQuery 3.x with .on() / .off() / .trigger() for modern namespaced event code.
100%jQuery support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
event.namespace1.4.3+
Bottom line: Safe for production plugins. Use dotted binds for isolation, .off(".namespace") for cleanup, and event.namespace to branch in shared handlers.
Analysis
Performance Notes
Approach
Cost
Best for
.on("click.ns", fn)
Cheap
Isolating plugin handlers
.off(".ns")
Cheap
Plugin destroy / teardown
Branch on event.namespace
Cheap
Shared custom-event handlers
Many unique namespaces
Slightly more bookkeeping
Keep names short and consistent
Namespaces add almost no runtime cost. The win is cleaner teardown and safer coexistence — not micro-optimizing string splits.
Remember
Key Takeaways
Role: read the namespace suffix from a namespaced event.
Pair:event.type = base name; event.namespace = suffix.
Cleanup:.off(".myPlugin") removes only that namespace.
Empty: no namespace → "", not undefined.
One line: bind with type.namespace, read event.namespace, tear down with .off(".namespace").
Frequently Asked Questions
event.namespace is a String on the jQuery event object. It holds the namespace from a namespaced bind or trigger — for example .on("click.myPlugin", fn) sets event.namespace to "myPlugin" when that handler runs. Available since jQuery 1.4.3.
Append a dot and name after the event type: .on("click.myPlugin", handler) or .on("test.something", handler). The part after the first dot is stored in event.namespace (extra segments stay as "foo.bar").
event.type is the base name — "click", "test", "keydown". event.namespace is only the suffix — "myPlugin", "something", or "" when the binding that fired had no namespace.
Namespaces keep plugin handlers separate from app code, let you remove them with .off(".myPlugin"), and let shared handlers branch with event.namespace — especially for custom events.
event.namespace is an empty string "" — not undefined. Check with if (event.namespace) or compare to a name like event.namespace === "myPlugin".
No. It is read-only — jQuery sets it from the namespaced bind or trigger that ran the handler. Control it with distinct bind names or .trigger("type.namespace").