JavaScript Event target Property

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline Widely available
Instance property

What You’ll Learn

The target property is a read-only reference to the EventTarget the event was dispatched onto—for a click, usually the element that was clicked. Learn how it differs from currentTarget, how event delegation works, and MDN’s list demo—with five examples and try-it labs.

01

Kind

Instance property

02

Type

EventTarget

03

Means

Dispatch origin

04

vs

currentTarget

05

Pattern

Delegation

06

Status

Baseline widely

Introduction

When you click a button, your handler needs to know which element was involved. event.target answers that: it is the object the event was dispatched to.

If the listener is on a parent (bubbling), event.currentTarget is the parent while event.target is still the child that was clicked. That difference powers event delegation—one listener for many children.

💡
Beginner tip

Prefer event.target over the deprecated srcElement alias. Same idea, standard name.

Understanding Event.target

An instance property that references the object onto which the event was dispatched.

  • Value — the associated EventTarget.
  • Read-only — the browser sets it during dispatch.
  • Different from currentTarget — during bubble/capture, the listener host may not be the origin.
  • Delegation — listen on a parent; inspect target (often with closest).
  • Baseline Widely available on MDN (since July 2015); also in Web Workers.

📝 Syntax

JavaScript
event.target

Value

The associated EventTarget.

Typical pattern

JavaScript
button.addEventListener("click", (event) => {
  console.log(event.target);           // the clicked element
  console.log(event.target.nodeName);  // e.g. "BUTTON"
});

⚡ Quick Reference

GoalCode / note
Read originevent.target
Node nameevent.target.nodeName
Delegation itemevent.target.closest("li")
Listener hostevent.currentTarget
MDN statusBaseline Widely available (since July 2015)

🔍 At a Glance

Four facts to remember about Event.target.

Type
EventTarget

Read-only

Means
origin

Dispatched to

Pairs with
currentTarget

Listener host

Baseline
widely

Since Jul 2015

Examples Gallery

Examples follow MDN Event: target. Use View Output or Try It Yourself.

📚 Getting Started

Read the origin and compare it with the listener host.

Example 1 — Read event.target

Click a button and log which element was the target.

JavaScript
button.addEventListener("click", (event) => {
  console.log(event.target.nodeName); // "BUTTON"
  console.log(event.target.id);       // e.g. "save"
});
Try It Yourself

How It Works

When the listener is on the same element that was clicked, target and currentTarget match.

Example 2 — target vs currentTarget

Parent listener: target is the child; currentTarget is the parent.

JavaScript
parent.addEventListener("click", (event) => {
  console.log("target:", event.target.id);
  console.log("currentTarget:", event.currentTarget.id);
});
Try It Yourself

How It Works

This is the core mental model for bubbling and delegation.

📈 Delegation Patterns

MDN’s list demo and safer closest / matches filters.

Example 3 — Hide Clicked List Items (MDN)

One listener on ul; evt.target is the clicked li.

JavaScript
function hide(evt) {
  // evt.target = clicked 
  • // evt.currentTarget = parent
      evt.target.style.visibility = "hidden"; } ul.addEventListener("click", hide);
  • Try It Yourself

    How It Works

    You do not need a separate listener on every li.

    Example 4 — Safe Delegation with closest

    If the user clicks text or a nested span, walk up to the real item.

    JavaScript
    list.addEventListener("click", (event) => {
      const item = event.target.closest("li");
      if (!item || !list.contains(item)) return;
      out.textContent = "Clicked: " + item.textContent.trim();
    });
    Try It Yourself

    How It Works

    closest makes delegation robust when children contain nested markup.

    Example 5 — Filter with matches

    Only react when the target itself is a button with a data attribute.

    JavaScript
    toolbar.addEventListener("click", (event) => {
      const el = event.target;
      if (!(el instanceof Element) || !el.matches("button[data-action]")) {
        return;
      }
      out.textContent = "Action: " + el.dataset.action;
    });
    Try It Yourself

    How It Works

    Combine target with matches (or closest) to ignore irrelevant clicks.

    🚀 Common Use Cases

    • Identifying which button / link / row was activated.
    • Event delegation on lists, tables, and toolbars.
    • Comparing origin vs listener host while debugging bubble bugs.
    • Building one handler for dynamically added children.
    • Teaching the standard replacement for deprecated srcElement.

    🔧 How It Works

    1

    User interacts

    For example, a click lands on a child element.

    Input
    2

    Browser sets target

    event.target becomes that origin EventTarget.

    Origin
    3

    Listeners run

    On each listener, currentTarget is the attached element.

    Handlers
    4

    You branch on target

    Delegation and UI logic read event.target (often via closest).

    📝 Notes

    • MDN: Baseline Widely available (since July 2015) — no Deprecated / Experimental / Non-standard banner.
    • Available in Web Workers.
    • Read-only—do not assign event.target = ….
    • Prefer target over deprecated srcElement.
    • Related learning: currentTarget, srcElement, eventPhase, bubbles, JavaScript hub.

    Universal Browser Support

    Event.target is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. It is also available in Web Workers.

    Baseline · Widely available

    Event.target

    Read-only EventTarget the event was dispatched to — the foundation of clicks, forms, and event delegation.

    Universal Widely available
    Google Chrome Full support · Desktop & Mobile
    Full support
    Mozilla Firefox Full support · Desktop & Mobile
    Full support
    Apple Safari Full support · macOS & iOS
    Full support
    Microsoft Edge Full support · Chromium
    Full support
    Opera Full support · Modern versions
    Full support
    Internet Explorer Supported (legacy); also had srcElement alias
    Full support
    Event.target Excellent

    Bottom line: Use event.target for the origin, event.currentTarget for the listener host, and closest() for robust delegation.

    Conclusion

    Event.target is the standard, read-only origin of an event. Pair it with currentTarget to understand bubbling, and use it with closest for clean event delegation.

    Continue with timeStamp, currentTarget, eventPhase, or the JavaScript hub.

    💡 Best Practices

    ✅ Do

    • Use event.target for the origin element
    • Use closest when children have nested markup
    • Compare with currentTarget while learning bubble
    • Guard with matches / contains in shared handlers
    • Prefer it over deprecated srcElement

    ❌ Don’t

    • Assign to event.target
    • Assume target always equals currentTarget
    • Attach dozens of identical listeners when one parent will do
    • Forget nested clicks (span inside button / li)
    • Write new srcElement code

    Key Takeaways

    Knowledge Unlocked

    Five things to remember about target

    The standard origin pointer for every Event.

    5
    Core concepts
    🔁02

    vs

    currentTarget

    Compare
    📋03

    Delegation

    one parent listener

    Pattern
    🔍04

    closest

    robust lookups

    DOM
    🎯05

    Baseline

    since Jul 2015

    Status

    ❓ Frequently Asked Questions

    It is a read-only property on an Event. It references the EventTarget onto which the event was dispatched—for a click, usually the element that was clicked.
    No. MDN marks Event.target as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. It is also available in Web Workers.
    target is where the event originated (the dispatch target). currentTarget is the element whose listener is running right now. They differ during bubbling or capturing when a parent listens for a child event.
    You attach one listener to a parent and use event.target (often with closest) to find which child was interacted with. MDN’s list example hides the clicked li via evt.target.
    event.srcElement is a deprecated alias for event.target. Always write event.target in new code.
    Sometimes engines retarget clicks over text to the parent element. Prefer event.target for portable code; Mozilla-only fields like originalTarget are non-standard.
    Did you know?

    Inside an event handler, this (for a classic function listener) is often the same as event.currentTarget—not necessarily event.target. Arrow functions do not bind this that way, so prefer reading event.target / event.currentTarget explicitly.

    Next: timeStamp

    Read when an event was created and measure deltas between actions.

    timeStamp →

    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.

    5 people found this page helpful