JavaScript Event srcElement Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

The deprecated srcElement property of the Event interface is an alias for Event.target (MDN). Use event.target instead.

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use event.srcElement. Start with this line.

JavaScript
event.srcElement
CallWhat it does
event.srcElementPrimary signature.

Built into the browser. Read event.srcElement on an Event instance — no import required.

Library declarations
JavaScript
event.srcElement

Parameters

ParameterDescription
currentTargetOptional. Element running this listener
DelegationOptional. Parent listens; inspect target

Return Value

Return ValueDescription
*The current value of event.srcElement.

JavaScript Examples

Example 1 — Legacy srcElement

Old IE-style code you may still see in the wild.

JavaScript
document.getElementById("btn").onclick = function (event) {
  const el = event.srcElement; // deprecated
  console.log(el.id);
};
Try It Yourself

How It Works

  1. Click fires on the button.
  2. Read srcElement. Legacy name for the origin node.
  3. Log its id. Same result as using target.
  4. Do not copy this into new projects — migrate next.

Example 2 — Prefer event.target

Same intent with the standard property (MDN replacement).

JavaScript
document.getElementById("btn").addEventListener("click", (event) => {
  console.log(event.target.id);
});
Try It Yourself

How It Works

  1. Use addEventListener. Clearer than assigning onclick.
  2. Read event.target. Standard originating target.
  3. Same value as the old srcElement alias.
  4. This is the code to keep in production.

Example 3 — target vs currentTarget

When a parent listens, origin and listener can differ.

JavaScript
parent.addEventListener("click", (event) => {
  console.log(event.target.id);        // child that was clicked
  console.log(event.srcElement.id);    // same (deprecated)
  console.log(event.currentTarget.id); // parent
});
Try It Yourself

How It Works

  1. Parent listens for bubbled clicks.
  2. target / srcElement name the clicked child.
  3. currentTarget is the parent running the handler.
  4. Migrate by dropping srcElement; keep target.

Browser Support

Event.srcElement is marked Deprecated on MDN. Engines still implement it as an alias of target for compatibility. New code should use event.target. Also available in Web Workers (still deprecated).

✓ Deprecated

Event.srcElement

Legacy alias of Event.target — migrate to event.target.

Legacy Deprecated
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
srcElement Prefer event.target

Bottom line: Supported for compatibility, not for new APIs. Prefer event.target. See the MDN srcElement reference.

Frequently Asked Questions

It is a deprecated alias for Event.target. It refers to the same EventTarget the event was dispatched to (MDN). Use Event.target instead.
MDN marks Event.srcElement as Deprecated. Prefer Event.target. It is not labeled Experimental or Non-standard on that MDN page. Also available in Web Workers.
Older Internet Explorer code used event.srcElement. Modern browsers keep it as a compatibility alias so legacy pages keep working.
No. Always write event.target. Learn srcElement only to read or migrate old code.
target / srcElement is where the event originated. currentTarget is the element whose listener is running right now (important when bubbling).
In supporting browsers they refer to the same target. Prefer reading event.target so your code matches the standard name everywhere.

Next: target

Learn the standard Event.target property in depth.

target 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