jQuery event.type Property

Beginner
5 min read
Updated: Oct 2026
5 examples
Live preview

What Is event.type?

event.type is a String that describes the nature of the event — "click", "keydown", or a custom name like "saveDraft". Since jQuery 1.0. It is the base name only (no namespace). Works with native events and .trigger().

Remember
event.type          // "click", "keydown", "saveDraft", …
event.namespace     // "myPlugin" for click.myPlugin (or "")

// Official pattern
$("a").on("click", function (event) {
  alert(event.type);   // "click"
});
NeedUse
What kind of event?event.type
Namespace suffix?event.namespace
Fire a custom name.trigger("name")
Bind handlers.on()
Remove by namespace.off(".ns")

How to Use event.type

Read it inside any handler to learn which event fired.

  1. Bind with .on("click", fn) or multi: .on("click keydown", fn).
  2. Inside the handler, read event.type.
  3. Branch with if / switch when one function handles several events.
  4. For customs, bind and .trigger("saveDraft") — type is "saveDraft".
  5. Remember: namespaces do not appear in type.
PieceRequired?Role
event argumentYesjQuery event object
event.typeYes (to inspect)Base event name string
Multi-event bindOptionalOne handler, branch on type
.trigger(name)OptionalCustom types

Pseudocode

Pseudocode
element.on("click keydown saveDraft", handler)

when an event fires:
    type = event.type   // "click" | "keydown" | "saveDraft"

    switch type:
        case "click":    handle click
        case "keydown":  handle key
        case "saveDraft": handle custom

    // click.myPlugin → type is still "click"

Cheat Sheet

Keep these facts handy while reading event names.

TopicDetail
TypeProperty → String
SincejQuery 1.0
MeaningNature / base name of the event
Examplesclick, keydown, saveDraft
NamespaceNot included — see event.namespace
Custom eventsSame property via .trigger()

Live Preview

Click a link — the log shows event.type, like the official demo.

Links

Every anchor click reports the same base type string.

Log
Click a link.

jQuery Examples

Short labs — each has View Output, Try It Yourself, and How It Works.

Example 1 — Official Anchor Click

Show event.type on every link click.

jQuery
$("a").on("click", function (event) {
  event.preventDefault();
  $("#out").text("event.type: " + event.type);
});
Try It Yourself

How It Works

  1. Bind click. All anchors share one handler.
  2. Prevent default. Stay on the page for the demo.
  3. Read type. Always the string "click".
  4. Official match. Same idea as the API alert demo.

Example 2 — Multi-Event Handler

One function for click, mouseenter, and mouseleave.

jQuery
$("#box").on("click mouseenter mouseleave", function (event) {
  $("#out").text("Fired: " + event.type);
});
Try It Yourself

How It Works

  1. One bind. Space-separated event list.
  2. Each fire. type matches that event.
  3. Shared logic. Log or branch without three handlers.
  4. Pattern. Great for simple UI feedback.

Example 3 — Custom saveDraft

Trigger a custom event; read its type in the handler.

jQuery
$("#editor").on("saveDraft", function (event) {
  $("#out").text("Draft saved (type: " + event.type + ")");
});

$("#save").on("click", function () {
  $("#editor").trigger("saveDraft");
});
Try It Yourself

How It Works

  1. Bind custom. Listen for saveDraft.
  2. Trigger. Button fires it on the editor.
  3. Type. Handler sees "saveDraft".
  4. Takeaway. Customs use the same property as natives.

Example 4 — Switch on Type

One container handler branches by event.type.

jQuery
$("#app").on("click submit keydown", function (event) {
  switch (event.type) {
    case "click":
      $("#out").text("Click inside #app");
      break;
    case "submit":
      event.preventDefault();
      $("#out").text("Form submitted");
      break;
    case "keydown":
      $("#out").text("Key: " + event.type);
      break;
  }
});
Try It Yourself

How It Works

  1. Delegate area. #app hears several events.
  2. Switch. Route by event.type.
  3. Submit. Call preventDefault() in that case.
  4. Scale. Add cases without new binds.

Example 5 — Type vs Namespace

Namespaced clicks share type; namespace differs.

jQuery
$("#btn").on("click.pluginA", function (event) {
  $("#out").append("A → type: " + event.type +
    ", ns: " + event.namespace + "\n");
});
$("#btn").on("click.pluginB", function (event) {
  $("#out").append("B → type: " + event.type +
    ", ns: " + event.namespace + "\n");
});
Try It Yourself

How It Works

  1. Two binds. click.pluginA and click.pluginB.
  2. Same type. Both report "click".
  3. Different ns. event.namespace tells them apart.
  4. Rule. Type = base; namespace = dotted suffix.

Edge Cases & Pitfalls

Watch for these when reading event names.

ns

No namespace in type

click.foo still has type === "click". Use event.namespace for foo.

case

Lowercase names

jQuery event names are lowercase ("click", not "Click"). Match that in switch/if.

orig

Prefer event.type

Synthetic triggers may lack originalEvent. Rely on event.type in jQuery handlers.

multi

Shared multi-handlers

Always branch on event.type — otherwise click and mouseenter share the wrong logic.

Browser Support

event.type is a standard DOM Event property. jQuery exposes it on the normalized event object since 1.0. Works wherever your loaded jQuery version runs.

✓ Stable · Event property

event.type

Supported in all modern browsers via the DOM Event API. Prefer jQuery 3.x for a consistent event object across native and custom events.

100% Property support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
type Universal

Bottom line: Safe for production. Use type for the base name; use namespace for the dotted suffix; use .trigger() for custom names.

Performance Notes

ApproachCostBest for
Read event.typeFreeIdentifying the event
Multi-event one handlerCheapShared UI feedback
Separate binds per typeFineVery different logic per event
Custom .trigger()TinyApp-level messaging

Reading type has no meaningful cost. Prefer one multi-event handler when the logic is similar; split binds when branches grow large.

Key Takeaways

  • Role: String describing the nature of the event.
  • Base only: no namespace in type.
  • Multi / custom: branch on type; customs work too.
  • Prefer: event.type over originalEvent.type.

One line: event.type answers “what kind of event is this?”

Frequently Asked Questions

event.type is a String 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 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.
Yes. Bind .on("click mouseenter mouseleave", fn) and branch with event.type — each dispatch sets type to whichever event fired.
Yes. When you .trigger("saveDraft") or bind .on("saveDraft", fn), event.type is "saveDraft". jQuery sets type for native DOM events and custom triggers alike.
Usually yes for native DOM events. For synthetic jQuery triggers with no underlying DOM event, originalEvent may be undefined while event.type still holds the triggered name. Prefer event.type in jQuery handlers.

Next: event.pageX

Read the horizontal mouse position relative to the document.

event.pageX tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful