event.type is a String that names the event — "click", "keydown", or any custom name you trigger. This tutorial covers the official anchor demo, multi-event shared handlers, custom events, delegated switch patterns, comparing with event.namespace and originalEvent.type, and five try-it labs.
01
Property
event.type
02
Returns
String
03
Official
Anchor click
04
Multi-bind
One handler
05
Custom
.trigger()
06
Since 1.0
Read-only
Fundamentals
Introduction
Every jQuery handler receives an event object. Among its properties, event.type answers: what kind of event fired? The value is a string — the base event name without any namespace suffix. For a user click it is "click"; for a custom save hook it might be "saveDraft".
jQuery has exposed event.type since version 1.0. The official docs show the simplest case: bind click on anchors and alert(event.type) displays "click". The property works with native DOM events, jQuery .trigger(), and fully custom event names. When you bind multiple types to one function — .on("click mouseenter", fn) — read event.type inside to branch behavior.
Concept
Understanding event.type
event.type describes the nature of the event as a plain string:
Base name only — for click.myPlugin, type is "click"; the suffix lives on event.namespace.
Native and synthetic — browser events, jQuery triggers, and custom names all set type consistently.
Read-only — jQuery assigns it when the event is created; you cannot change which type fired.
Shared handlers — one callback bound to several types uses event.type to decide what to run.
💡
Beginner Tip
Need the dotted plugin suffix? Read event.namespace. Need the event kind — click vs keydown vs custom? Read event.type. They complement each other on namespaced binds.
Foundation
📝 Syntax
Official jQuery API form (since 1.0):
jQuery
event.type
// read inside any .on() handler:
function handler( event ) {
console.log( "Event type:", event.type );
}
// multi-event bind — branch on type:
$( "#box" ).on( "click mouseenter mouseleave", function ( event ) {
if ( event.type === "click" ) { /* ... */ }
});
Type
String — the base event name, e.g. "click", "keydown", "saveDraft".
Return value
Not a method — a read-only property on the event object passed to your handler.
Does not include namespace dots — compare with the full bind string via type + namespace together.
Official jQuery API example
jQuery
$( "a" ).on( "click", function ( event ) {
alert( event.type ); // "click"
});
Cheat Sheet
⚡ Quick Reference
Bind / trigger
event.type
event.namespace
"click"
click
""
"click.myPlugin"
click
myPlugin
"keydown"
keydown
""
"saveDraft" (custom)
saveDraft
""
Multi-bind string
.on("click mouseenter", fn) — type varies per dispatch
Compare
📋 event.type vs event.namespace vs originalEvent.type vs bind string
Four related pieces — the bind string splits; jQuery exposes type and namespace separately on its event object.
Bind string
"click.pluginA"
What you pass to .on() or .trigger()
event.type
event.type
Base name — "click" (no dot suffix)
event.namespace
event.namespace
Dotted suffix — "pluginA" or ""
originalEvent.type
event.originalEvent.type
Native DOM type when present; prefer event.type in jQuery code
Hands-On
Examples Gallery
Example 1 follows the official anchor click demo. Examples 2–5 cover multi-event handlers, custom triggers, delegated switch patterns, and type vs namespace on namespaced clicks.
📚 Official jQuery Demo
Alert the event type on every anchor click.
Example 1 — Official Demo: alert type on anchor click
Official jQuery pattern — bind click on all anchors; alert(event.type) shows "click".
jQuery
$( "a" ).on( "click", function ( event ) {
alert( event.type ); // "click"
});
Click any <a> link → alert shows: click
event.type is always the base name — never "click.something"
How It Works
When the browser dispatches a click, jQuery normalizes it and sets event.type to "click". The official demo proves the property is available on the simplest bind.
Example 2 — Multi-event handler: click, mouseenter, mouseleave
One function bound to three types — log event.type to see which fired.
jQuery registers one handler for each listed type but runs the same callback. event.type tells you which of the three actually dispatched — the core pattern for shared utility functions.
📈 Practical Patterns
Custom events, delegated switches, and namespace comparison.
Example 3 — Custom event: trigger saveDraft
Bind and trigger a custom name — handler checks event.type === "saveDraft".
Click #save → trigger saveDraft on #editor
#status → "Draft saved (type: saveDraft)"
Custom names work the same as native types on event.type
How It Works
jQuery custom events are just strings. .trigger("saveDraft") sets event.type to "saveDraft" — no DOM event required for the type property to be meaningful.
Example 4 — Switch on event.type: delegated handler on #app
One delegated bind for click submit keydown — branch with a switch on event.type.
Click in #app → "Click inside #app"
Submit form → "Form submitted" (default prevented)
Keydown in #app → "Key: keydown"
How It Works
Event delegation plus multi-type binding keeps one listener on a container. event.type drives the switch — cleaner than three separate handlers when logic shares setup and logging.
Example 5 — type vs namespace: click.pluginA and click.pluginB
Two namespaced click binds — log event.type (always click) vs event.namespace (pluginA or pluginB).
Namespaced binds split the string: type is always the segment before the first dot. Both plugin handlers see event.type === "click" but different event.namespace values — never confuse the two properties.
Applications
🚀 Common Use Cases
Logging and debugging — print event.type when many handlers attach to one element.
Custom event routing — .trigger("saveDraft") sets type to your application event name.
Delegated containers — one #app listener for click, submit, and keydown via switch.
Plugin vs app code — type stays "click"; use namespace to tell plugins apart.
Testing — assert event.type after simulated triggers in unit tests.
🧠 How event.type Is Set
1
Bind or trigger
You pass an event name — click, keydown, saveDraft, or click.myPlugin — to .on() or .trigger().
Setup
2
jQuery parses
Splits namespaced strings: base name becomes event.type; dotted suffix goes to event.namespace.
Parse
3
Event dispatches
Native DOM action, user input, or .trigger() fires the handler with a normalized jQuery event object.
Dispatch
4
✓
Read event.type
Your callback reads the String — "click", "keydown", or custom — and branches or logs accordingly.
Important
📝 Notes
Available since jQuery 1.0 — returns a String describing the event nature.
Read-only property — jQuery sets it; you cannot reassign which type fired.
Base name only — for click.myPlugin, type is "click"; namespace is on event.namespace.
Works with native DOM events, .trigger(), and custom event names.
Multi-bind handlers rely on event.type to distinguish click vs mouseenter vs keydown in one function.
Prefer event.type over event.originalEvent.type in jQuery handlers — originalEvent may be absent on pure triggers.
Not a function — access as event.type, never event.type().
Compatibility
Browser Support
event.type mirrors the standard DOM Event type property on jQuery’s normalized event object since jQuery 1.0+. All modern browsers expose type on native events; jQuery copies it consistently for triggers and custom events.
✓ jQuery 1.0+ · DOM standard
jQuery event.type
Base event name as a String.
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
typeString
Bottom line: Native clicks, keydowns, and custom triggers all set event.type.
Wrap Up
Conclusion
event.type tells you what kind of event fired — a String like "click" or "saveDraft" since jQuery 1.0. The official demo alerts it on anchor clicks; shared handlers and delegated switches branch on the same property.
Pair it with event.namespace when binds use dotted suffixes, and prefer event.type over digging into originalEvent in everyday jQuery code.
Branch shared handlers with if (event.type === "click") or switch
Log event.type alongside event.namespace when debugging namespaced binds
Use event.type for custom events triggered with .trigger("myEvent")
Combine multi-type binds on containers for delegated switch patterns
Assert event.type in tests after simulated user actions
❌ Don’t
Call event.type() with parentheses — it is a property
Expect type to include namespace dots — read event.namespace instead
Assign to event.type — it is read-only
Assume originalEvent.type always exists on jQuery-only triggers
Duplicate handlers when one multi-bind plus event.type suffices
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about event.type
Base event name — branch in shared handlers.
5
Core concepts
type01
event.type
String name
API
1.002
Since 1.0
Core property
History
demo03
Official
alert click
Demo
multi04
Multi-bind
One handler
Pattern
ns05
namespace
Not in type
Pair
❓ Frequently Asked Questions
event.type is a String property on the jQuery event object. It describes the nature of the event — for example "click", "keydown", or a custom name like "saveDraft". Available since jQuery 1.0. It is read-only and holds the base event name without any namespace suffix.
Bind click on anchors: $("a").on("click", function(event) { alert(event.type); }); // "click". The alert shows the base type string for every anchor click.
For a bind like click.myPlugin, event.type is "click" (the base name) and event.namespace is "myPlugin" (the dotted suffix). event.type never includes the namespace — use event.namespace for that part.
Yes. Bind .on("click mouseenter mouseleave", fn) and branch inside with event.type — each dispatch sets type to whichever event fired. One function can serve click, hover enter, and hover leave logic.
Yes. When you .trigger("saveDraft") or bind .on("saveDraft", fn), event.type is "saveDraft". jQuery sets type from native DOM events, .trigger() calls, and custom event names alike.
Usually yes for native DOM events — jQuery copies the native type onto event.type. For purely synthetic jQuery triggers with no underlying DOM event, event.originalEvent may be undefined while event.type still holds the triggered name. Prefer event.type in jQuery handlers.
Did you know?
event.type has been part of the jQuery event object since version 1.0 — one of the oldest properties in the API. The DOM Level 2 Events specification standardized the same type field on native events, and jQuery’s wrapper has mirrored it ever since, including for purely synthetic .trigger() calls that never touch the browser’s event queue.