jQuery event.target

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Event object · jQuery 1.0+

What You’ll Learn

event.target is the DOM element that initiated the event — often a nested child when you click buttons with icons or list rows with links. This tutorial covers the official body click demo, ul delegation toggle, comparing with currentTarget, this, and relatedTarget, and the closest() toolbar pattern.

01

Property

event.target

02

Returns

Element (DOM)

03

Official

Body nodeName

04

Delegate

Filter with .is()

05

vs this

Bubble detect

06

Since 1.0

All events

Introduction

Every jQuery handler receives an event object. Among its properties, event.target answers: which DOM element did the user actually interact with? That is not always the element you bound the handler to — nested markup means the target can be a child span, icon, or link while the handler runs on a parent.

jQuery has exposed event.target since version 1.0. The official docs note it can be the element that registered for the event or a descendant of it. Comparing event.target to this reveals whether the event is being handled due to bubbling — and the property is especially useful in event delegation when events bubble up to a single parent listener.

Understanding event.target

event.target points at the element where the browser fired the event — the deepest node in the interaction:

  • Direct click — click a button with no nested elements → target equals the button.
  • Nested click — click an icon inside the button → target is the icon; handler on the button still runs via bubbling.
  • Delegation — one handler on ultarget is whatever was clicked; filter before acting.
  • Fixed for the event — unlike currentTarget, target stays the same as the event bubbles through ancestors.
💡
Beginner Tip

Wrap with jQuery when you need methods: var $t = $( event.target );. Use $t.is( "li" ), $t.closest( ".tool" ), or $t.hasClass( "disabled" ) to decide what to do.

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
event.target

// read inside any .on() handler:
function handler( event ) {
  var el = event.target;
  $( "#log" ).html( "clicked: " + event.target.nodeName );
}

// compare to this — bubbling detection:
if ( event.target === this ) {
  // direct hit on bound element
}

Type

  • Element — a native DOM element (wrap with $( event.target ) for jQuery methods).

Return value

  • Not a method — a read-only property on the event object passed to your handler.
  • Always defined when jQuery invokes your callback for a DOM event.

Official jQuery API examples

jQuery
$( "body" ).on( "click", function ( event ) {
  $( "#log" ).html( "clicked: " + event.target.nodeName );
});
jQuery
function handler( event ) {
  var target = $( event.target );
  if ( target.is( "li" ) ) {
    target.children().toggle();
  }
}
$( "ul" ).on( "click", handler ).find( "ul" ).hide();

⚡ Quick Reference

ReferencePoints toChanges while bubbling?
event.targetDeepest event originNo — fixed for the event
event.currentTargetElement whose handler runs nowYes — each handler sees itself
thisMatched element / handler contextPer handler
$(event.target).closest(sel)Nearest ancestor matching selectorN/A — traversal from origin
event.target === thisDirect vs bubbled hit testPer handler

📋 target vs currentTarget vs this vs relatedTarget

Four event references beginners mix up — use the right one for each job.

target
event.target

Click origin (deepest node)

currentTarget
event.currentTarget

Handler owner during bubble

this
$(this)

Matched element / scope

relatedTarget
event.relatedTarget

Other element in mouse transition

Examples Gallery

Example 1 follows the official body click demo. Examples 2–5 cover ul delegation, target vs currentTarget, target vs this under delegation, and the toolbar closest() pattern.

📚 Official jQuery Demo

Log the tag name of whichever nested element initiated the click.

Example 1 — Official Demo: body click logs event.target.nodeName

Official jQuery pattern — click nested span, strong, or p blocks; #log shows the initiating element’s tag name.

jQuery
$( "body" ).on( "click", function ( event ) {
  $( "#log" ).html( "clicked: " + event.target.nodeName );
});
Try It Yourself

How It Works

The click bubbles to body, but event.target stays the deepest element clicked — not the body itself. Reading nodeName reveals which nested block initiated the event.

Example 2 — Official Demo: ul delegation toggles nested lists

Official delegation pattern — one handler on ul; when $( event.target ).is( "li" ), toggle that row’s nested ul children.

jQuery
function handler( event ) {
  var target = $( event.target );
  if ( target.is( "li" ) ) {
    target.children().toggle();
  }
}
$( "ul" ).on( "click", handler ).find( "ul" ).hide();
Try It Yourself

How It Works

Delegation attaches one listener on the parent ul. Inspecting event.target tells you which child was clicked — filter with .is( "li" ) before toggling so only row clicks expand submenus.

📈 Practical Patterns

Compare references, detect bubbling, and resolve nested toolbar clicks.

Example 3 — vs event.currentTarget: nested span in button

Click the icon span inside a button — log both target and currentTarget to see origin vs handler owner.

jQuery
$( "#save" ).on( "click", function ( event ) {
  console.log( "target:", event.target.tagName );              // "SPAN"
  console.log( "currentTarget:", event.currentTarget.id );     // "save"
});
Try It Yourself

How It Works

event.target is fixed at the deepest clicked node. event.currentTarget is the element whose listener runs — the button you bound to, not the nested icon.

Example 4 — vs this in delegation: direct vs bubbled hit

Body-level handler compares event.target to this — when they differ, the click bubbled from a descendant.

jQuery
$( "body" ).on( "click", "#panel", function ( event ) {
  if ( event.target === this ) {
    $( "#log" ).text( "Direct click on #panel" );
  } else {
    $( "#log" ).text(
      "Bubbled from " + event.target.tagName +
      " (target !== this)"
    );
  }
});
Try It Yourself

How It Works

When event.target === this, the user hit the bound element directly. When they differ, a child initiated the event and it bubbled — the pattern jQuery documents for distinguishing direct vs delegated bubbling.

Example 5 — Toolbar icons: $( event.target ).closest( ".tool" )

Buttons contain nested icons — resolve the logical tool with closest() instead of assuming event.target is the button.

jQuery
$( "#toolbar" ).on( "click", ".tool", function ( event ) {
  var tool = $( event.target ).closest( ".tool" );
  $( "#status" ).text(
    "Activated: " + tool.data( "action" )
  );
});
Try It Yourself

How It Works

event.target may be a nested icon or label. $( event.target ).closest( ".tool" ) walks up to the logical control — safer than using this alone when the matched selector and click origin differ inside complex markup.

🚀 Common Use Cases

  • Event delegation — one parent handler filters $( event.target ) with .is() or .closest().
  • Bubbling detectionevent.target === this to ignore bubbled child clicks on container handlers.
  • Nested buttons — icons inside buttons — read target, act on currentTarget or closest().
  • Table row actions — detect which cell or link was clicked inside a delegated row handler.
  • Ignore disabled regions — bail out when $( event.target ).closest( ".disabled" ).length.
  • Debug logging — log event.target.nodeName during development to trace unexpected click origins.

🧠 How event.target Is Set

1

User action

Browser fires a native event at the deepest element under the pointer or focus — that element becomes target.

Trigger
2

jQuery normalizes

Your handler receives jQuery’s event object with event.target copied from the native event — an Element reference.

Handler
3

Bubbling continues

Parent handlers run — each sees a different currentTarget, but target stays the original origin.

Bubble
4

Inspect and filter

Wrap with $( event.target ), compare to this, or use closest() to decide what logic to run.

📝 Notes

  • Available since jQuery 1.0 — returns a native DOM Element.
  • Can be the element that registered for the event or a descendant of it.
  • Compare to this to determine if handling is due to event bubbling.
  • Very useful in event delegation when events bubble to a parent listener.
  • Do not confuse with event.currentTarget — target is origin; currentTarget is handler owner.
  • Do not confuse with event.relatedTarget — that property applies to mouseover/mouseout transitions.
  • Read-only — wrap with $( event.target ) for jQuery traversal methods.

Browser Support

event.target is a standard DOM Event property exposed on jQuery’s normalized event object since jQuery 1.0+. It behaves consistently anywhere jQuery runs — the property reflects the deepest element that initiated the event.

jQuery 1.0+ · DOM standard

jQuery event.target

Event origin element — fixed while bubbling.

100% Universal
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
target DOM Element

Bottom line: Use target for origin; currentTarget for handler owner.

Conclusion

event.target is the DOM element that initiated the event — the deepest node the user interacted with. The official body click demo shows how nested clicks report different tag names, and the ul delegation pattern filters $( event.target ) before toggling nested lists.

Pair target with currentTarget or this when nested markup matters, and reach for closest() when icons or labels sit inside toolbar buttons.

💡 Best Practices

✅ Do

  • Wrap event.target with $( event.target ) for .is(), .closest(), and .hasClass()
  • Compare event.target === this to detect direct vs bubbled clicks
  • Filter delegated handlers — only act when target.is( selector ) matches
  • Use closest() on target when nested icons break simple this assumptions
  • Log target, currentTarget, and this while learning delegation

❌ Don’t

  • Assume event.target === event.currentTarget on buttons with nested icons
  • Assume event.target === this under delegation — this is the matched child
  • Use target when you mean the handler owner — use currentTarget
  • Confuse event.target with CSS :target or jQuery :target selector
  • Mutate event.target — it is read-only

Key Takeaways

Knowledge Unlocked

Five things to remember about event.target

Event origin — fixed while bubbling.

5
Core concepts
El 02

Element

DOM node

Type
demo 03

Official

Body + ul

Demo
=== 04

vs this

Bubble detect

Pattern
05

closest

Nested icons

Tool

❓ Frequently Asked Questions

event.target is the DOM element that initiated the event — the deepest element the user interacted with. jQuery exposes it on the normalized event object since version 1.0. It returns a native Element, not a jQuery collection.
event.target is where the event started — the element clicked or typed into. event.currentTarget is the element whose handler is running as the event bubbles. Click a span inside a button: target is the span; currentTarget on the button handler is the button.
Compare them to detect direct vs bubbled handling. When event.target === this, the user interacted with the bound element itself. When they differ, the event bubbled up from a descendant — common with nested icons, links inside rows, or delegated parents.
Bind one handler on a parent, then inspect $(event.target) to see what was actually clicked. Filter with .is(), .closest(), or .matches() before acting — the official ul demo uses target.is('li') to toggle nested lists only when an li was clicked.
The official API binds click on body and sets #log to 'clicked: ' + event.target.nodeName — showing SPAN, STRONG, or P depending on which nested block you click.
No. event.target is the element that received the current event (e.g. the link on click). event.relatedTarget is the other element in a mouseover/mouseout transition — where the pointer came from or is going. relatedTarget applies to mouse events; target applies to all event types.
Did you know?

event.target has been part of jQuery’s event object since version 1.0 — one of the oldest event properties in the library, predating event.currentTarget (1.3) and event.delegateTarget (1.7). The native DOM specification uses the same name and semantics, so code reading event.target works in both jQuery handlers and vanilla addEventListener callbacks.

Next: event.data

Learn how to pass custom objects to handlers and fix loop closure bugs.

event.data 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.

6 people found this page helpful