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