Event()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Event()
constructor 能用來建立一個 事件
。
語法
event = new Event(typeArg, eventInit);
參數
- typeArg
-
為一
DOMString
,用來表示事件名稱。 - eventInit選擇性
-
一個
EventInit
object,包含以下欄位
範例
js
// 建立一個 bubbles up 、並未被取消的事件 「look」 。
var ev = new Event("look", { bubbles: true, cancelable: false });
document.dispatchEvent(ev);
規範
Specification |
---|
DOM Standard # ref-for-dom-event-event |
瀏覽器相容性
BCD tables only load in the browser