Get to know MDN better
此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
submit 事件會在 <form> 被提交時觸發。
請注意 submit 事件是在 <form> 元素本身觸發,而不是在內部的任何 <button> 或 <input type="submit"> 上觸發。然而,用來表示表單提交動作已被觸發的 SubmitEvent 包含一個 submitter 屬性,即為被呼叫以觸發提交請求的按鈕。
submit 事件會在下列情況下觸發:
然而,當指令碼直接呼叫 form.submit() 方法時,此事件不會發送給表單。
在 addEventListener() 等方法中使用事件名稱,或設定事件處理器屬性。
一個 SubmitEvent。繼承自 Event。
Event SubmitEvent除了下列列出的屬性外,此介面也繼承其父介面 Event 的屬性。
submitter Read only一個 HTMLElement 物件,用來識別被呼叫以觸發表單提交的按鈕或其他元素。
本範例使用 EventTarget.addEventListener() 監聽表單提交,並在發生時記錄當下的 Event.timeStamp,接著阻止提交表單的預設行為。
| HTML # event-submit |
| HTML # handler-onsubmit |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2026年1月7日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.