JavaScript Event srcElement Property

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Instance property

What You’ll Learn

The srcElement property is a deprecated alias for Event.target—the element (or other EventTarget) the event is aimed at. Learn why old code used it, how it differs from currentTarget, and how to migrate—with five examples and try-it labs.

01

Kind

Instance property

02

Type

EventTarget

03

Alias of

event.target

04

Modern

Use target

05

Status

Deprecated

06

Workers

Also available

Introduction

Today every beginner tutorial says: read event.target to learn which element was clicked. Decades ago, Internet Explorer used a different name: event.srcElement.

Modern browsers still expose srcElement as a compatibility alias so old scripts keep working. MDN is clear: treat it as deprecated and write event.target in all new code.

💡
Beginner tip

When you find event.srcElement in a codebase, replace it with event.target. Same meaning, standard name.

Understanding Event.srcElement

An instance property that is simply another name for Event.target.

  • Alias — same target object as event.target.
  • Deprecated — keep for legacy reading; do not teach as the primary API.
  • Origin — historically associated with older IE event models.
  • Not currentTarget — that is the listener host during bubbling.
  • Web Workers — MDN notes it is available in workers.

📝 Syntax

JavaScript
event.srcElement // deprecated alias
event.target     // use this instead

Value

The same EventTarget as event.target (or null in the same situations target would be).

Migration one-liner

JavaScript
// Before (legacy):
// const el = event.srcElement;

// After (modern):
const el = event.target;

⚡ Quick Reference

GoalLegacyModern
Get clicked elementevent.srcElementevent.target
Get listener hostevent.currentTarget
Compare aliasevent.srcElement === event.target (typically)
MDN statusDeprecated — use Event.target

🔍 At a Glance

Four facts to remember about Event.srcElement.

Role
alias

Of target

Status
deprecated

Legacy name

Prefer
target

Standard API

Not
currentTarget

Different idea

Examples Gallery

Examples follow MDN Event: srcElement. Compare the alias with target, then migrate.

📚 Getting Started

See the alias and prove it matches target.

Example 1 — Read srcElement (Legacy)

Log the node name the old way—then remember to prefer target.

JavaScript
button.addEventListener("click", (event) => {
  // Deprecated — for learning / legacy only:
  console.log(event.srcElement && event.srcElement.nodeName);
});
Try It Yourself

How It Works

Browsers that still support the alias return the same clicked button.

Example 2 — Same Object as event.target

Confirm the alias points at the identical target.

JavaScript
box.addEventListener("click", (event) => {
  console.log(event.srcElement === event.target); // usually true
  console.log("target:", event.target.nodeName);
});
Try It Yourself

How It Works

That equality is why migration is a simple rename.

📈 currentTarget & Migration

Do not confuse the alias with the listener host.

Example 3 — srcElement vs currentTarget

Click the child; parent listener shows different names.

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

How It Works

target/srcElement = origin. currentTarget = this listener’s element.

Example 4 — Migrate a Legacy Helper

Old code often normalized IE vs standards. Today you only need target.

JavaScript
// Legacy pattern (avoid writing new code like this):
function getTarget(event) {
  return event.target || event.srcElement;
}

// Modern:
function getTargetModern(event) {
  return event.target;
}

button.addEventListener("click", (event) => {
  console.log(getTargetModern(event).nodeName);
});
Try It Yourself

How It Works

The || srcElement fallback was for ancient IE. Modern engines already provide target.

Example 5 — Event Delegation with target

Prefer standard target (not srcElement) when delegating.

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

How It Works

Delegation is a perfect place to practice the modern name only.

🚀 Common Use Cases

  • Reading / migrating old IE-era event helpers.
  • Understanding why some tutorials still mention srcElement.
  • Teaching target vs currentTarget with a deprecated alias aside.
  • Code search cleanup: replace srcElement with target.
  • Interviews: know the alias, recommend the standard property.

🔧 How It Works

1

Event is dispatched

Browser sets the event’s target.

Dispatch
2

Standard property

event.target holds that EventTarget.

target
3

Legacy alias

event.srcElement exposes the same value for old code.

Alias
4

You use target

New code reads event.target only.

📝 Notes

Legacy / Deprecated Browser Support

Event.srcElement is marked Deprecated on MDN as an alias of Event.target. Logos use the shared browser-image-sprite.png sprite. Prefer event.target for all new code.

Deprecated · Prefer event.target

Event.srcElement

Deprecated alias for Event.target. Kept for compatibility with older code. Do not use in new apps.

Legacy Not for new apps
Google Chrome Alias supported for compatibility
Legacy OK
Mozilla Firefox Alias supported for compatibility
Legacy OK
Apple Safari Alias supported for compatibility
Legacy OK
Microsoft Edge Chromium compatibility path
Legacy OK
Opera Follow Chromium compatibility
Legacy OK
Internet Explorer Historical srcElement name
Legacy
Event.srcElement Deprecated

Bottom line: Rename srcElement → target during cleanup. Teach only event.target to beginners.

Conclusion

Event.srcElement is a deprecated alias for Event.target. Know it so legacy code makes sense—then always write event.target (and event.currentTarget when you need the listener host).

Continue with target, currentTarget, cancelBubble, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use event.target in every new handler
  • Replace srcElement during refactors
  • Pair with currentTarget for bubbling / delegation
  • Document legacy finds for your team
  • Teach beginners only the standard name

❌ Don’t

  • Write new event.srcElement code
  • Confuse it with currentTarget
  • Keep dead target || srcElement helpers without need
  • Assume it teaches a different concept than target
  • Skip migration when touching old event utilities

Key Takeaways

Knowledge Unlocked

Five things to remember about srcElement

A deprecated nickname for event.target.

5
Core concepts
🔗02

Alias

of target

Meaning
🎯03

Prefer

event.target

Modern
🔁04

Not

currentTarget

Compare
🛠️05

Migrate

rename only

Cleanup

❓ Frequently Asked Questions

It is a deprecated alias for Event.target. It refers to the same EventTarget the event was dispatched to (the originating target after the engine’s normal targeting rules).
Yes. MDN marks Event.srcElement as Deprecated and says to use Event.target instead. It is not labeled Experimental or Non-standard on that MDN page.
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 should refer to the same target. Prefer reading event.target so your code matches the standard name everywhere.
Did you know?

Many “cross-browser” snippets from the 2000s looked like var t = e.target || e.srcElement. That pattern is a fossil from the IE vs Netscape days. On today’s web, e.target alone is enough.

Next: target

Learn the standard Event.target property and event delegation.

target →

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