event.namespace is a String property with the namespace from a namespaced bind like click.myPlugin or test.something. This tutorial covers the official demo, plugin patterns, .off('.namespace') cleanup, comparing with event.type, and custom events.
01
Property
event.namespace
02
Returns
String
03
Official
test.something
04
Bind
type.name
05
Plugins
.off cleanup
06
Since 1.4.3
Read-only
Fundamentals
Introduction
jQuery lets you attach a namespace to event names by adding a dot suffix when binding: .on("click.myPlugin", fn). That keeps plugin handlers separate from app code and makes teardown easy with .off(".myPlugin").
Inside the handler, event.namespace tells you which namespace fired — useful when one function listens to several namespaced variants. jQuery has exposed this String property since version 1.4.3.
Concept
Understanding event.namespace
This property answers one question: which namespace was on the event that invoked this handler?
Namespaced bind — .on("test.something", fn) sets event.namespace to "something".
No namespace — plain .on("click", fn) gives event.namespace as "" (empty string).
Read-only — a property, not a function; set by jQuery from the bind/trigger string.
Multiple segments — click.foo.bar can yield event.namespace of "foo.bar".
💡
Beginner Tip
event.type is the base name (click, test). event.namespace is everything after the first dot in the bind string. They work together — do not confuse the full string "click.myPlugin" with either property alone.
Foundation
📝 Syntax
Official jQuery API form (since 1.4.3):
jQuery
event.namespace
// bind with a namespace:
$( "button" ).on( "click.myPlugin", function ( event ) {
console.log( event.type ); // "click"
console.log( event.namespace ); // "myPlugin"
});
Parameters
None — namespace is a property, not a method.
Return value
String — the namespace specified when the event was triggered; empty string when none was used.
Avoid collisions — isolate third-party binds from application click handlers.
🧠 How event.namespace Works
1
Bind or trigger
You pass a dotted string — click.myPlugin or test.something — to .on() or .trigger().
Setup
2
jQuery parses
Splits into event.type (before first dot) and event.namespace (after).
Parse
3
Handler runs
Your callback reads event.namespace — a String, or "" if none.
Read
4
✓
Plugin-safe code
Branch, log, or remove handlers by namespace without guessing bind strings.
Important
📝 Notes
Available since jQuery 1.4.3 — returns a String.
Read-only property — not a function.
Empty namespace is "", not undefined or null.
Do not confuse with event.type — type is the base event name only.
.off(".namespace") removes handlers in that namespace across event types on the element.
Primarily used by plugin authors; app code benefits when sharing handlers across namespaced binds.
Compatibility
Browser Support
event.namespace is a jQuery-specific event object property since jQuery 1.4.3+. It is set by jQuery when namespaced binds or triggers run — independent of native DOM event names.
✓ jQuery 1.4.3+ · all browsers
jQuery event.namespace
Read the namespace from namespaced events.
100%Universal
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
namespaceString
Bottom line: Bind click.myPlugin — read event.namespace in the handler.
Wrap Up
Conclusion
event.namespace exposes the dotted suffix from namespaced jQuery events — the official demo alerts something for test.something.
Use it with .off(".myPlugin") for plugin lifecycle, and pair with event.type when one handler serves multiple namespaced variants.
Log event.type and event.namespace together when debugging
Use unique namespace names per plugin (myWidget.v2)
Branch shared handlers with event.namespace === "success"
❌ Don’t
Call event.namespace() with parentheses
Assume namespace equals the full bind string
Forget empty string for non-namespaced handlers
Reuse generic namespaces like .plugin across libraries
Assign to event.namespace — it is read-only
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about namespace
Read the dotted suffix on jQuery events.
5
Core concepts
ns01
namespace
String property
API
type02
event.type
Base name
Pair
demo03
Official
something
Demo
off04
.off(".ns")
Cleanup
Use
plug05
Plugins
Isolate binds
Why
❓ Frequently Asked Questions
event.namespace is a String property on the jQuery event object. It holds the namespace portion of the event that fired — for example, binding with .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), .on('test.something', handler), or .on('custom.widget', handler). The part after the first dot is stored in event.namespace (multiple segments join with dots).
event.type is the base event name — 'click', 'test', 'keydown'. event.namespace is only the suffix you added — 'myPlugin', 'something', or empty string '' when no namespace was used on the binding that fired.
Namespaces let plugins bind handlers without clobbering other code, remove all plugin handlers with .off('.myPlugin'), and branch in shared utilities using event.namespace — especially on custom events.
event.namespace is an empty string '' — not undefined. Check with if (event.namespace) or compare to a specific name like event.namespace === 'myPlugin'.
No. It is read-only — jQuery sets it from the namespaced bind string or trigger call that caused the handler to run. Use distinct bind names or trigger('type.namespace') to control it.
Did you know?
jQuery introduced namespaced events so multiple plugins could bind to the same element without overwriting each other. event.namespace (added in 1.4.3) lets a single handler function distinguish which dotted suffix fired — long before custom DOM events were widely used.