值
相關聯的 EventTarget。
範例
event.target 屬性可用於實作事件委派。
js// 建立一個列表
const ul = document.createElement("ul");
document.body.appendChild(ul);
const li1 = document.createElement("li");
const li2 = document.createElement("li");
ul.appendChild(li1);
ul.appendChild(li2);
function hide(evt) {
// evt.target 指的是被點擊的
// 這與 evt.currentTarget 不同,在此上下文中的 currentTarget 指的是父層
- 被點擊時,它都會觸發
ul.addEventListener("click", hide);
規範
Specification
DOM# ref-for-dom-event-target③
瀏覽器相容性
參見
學習:事件冒泡
Help improve MDN
Was this page helpful to you?
Yes
No
Learn how to contribute
This page was last modified on 2026年3月3日 by MDN contributors.
View this page on GitHub • Report a problem with this content
evt.target.style.visibility = "hidden";
}
// 將監聽器附加到列表
// 當每個