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
Fundamentals
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.
Concept
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 ul → target 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.
Foundation
📝 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.
function handler( event ) {
var target = $( event.target );
if ( target.is( "li" ) ) {
target.children().toggle();
}
}
$( "ul" ).on( "click", handler ).find( "ul" ).hide();
Cheat Sheet
⚡ Quick Reference
Reference
Points to
Changes while bubbling?
event.target
Deepest event origin
No — fixed for the event
event.currentTarget
Element whose handler runs now
Yes — each handler sees itself
this
Matched element / handler context
Per handler
$(event.target).closest(sel)
Nearest ancestor matching selector
N/A — traversal from origin
event.target === this
Direct vs bubbled hit test
Per handler
Compare
📋 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
Hands-On
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.
Click span → #log shows "clicked: SPAN"
Click strong → "clicked: STRONG"
Click p → "clicked: P"
Handler is on body; target is the nested block you clicked
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();
Nested ul lists start hidden
Click an li row → its nested ul toggles open/closed
Click text inside li → target may be text node parent; .is("li") filters correctly when li is target
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.
target: SPAN (the icon you clicked)
currentTarget: save (the button handler owner)
Use currentTarget to style the whole button; target shows the nested hit
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)"
);
}
});
Click #panel background → "Direct click on #panel"
Click inner button → "Bubbled from BUTTON (target !== this)"
Official docs recommend this comparison for bubbling detection
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.
Click icon inside .tool button → #status shows "Activated: bold" (or save, undo)
closest(".tool") finds the button even when target is nested <span class="icon">
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.
Applications
🚀 Common Use Cases
Event delegation — one parent handler filters $( event.target ) with .is() or .closest().
Bubbling detection — event.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.
Important
📝 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.
Compatibility
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 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
targetDOM Element
Bottom line: Use target for origin; currentTarget for handler owner.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about event.target
Event origin — fixed while bubbling.
5
Core concepts
T01
target
Event origin
API
El02
Element
DOM node
Type
demo03
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.