HTML:標記語言
CSS:樣式語言
JavaScript:指令碼語言
Web API:程式設計介面
所有 Web 技術
學習 Web 開發
發現我們的工具
更好地瞭解 MDN
此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。
CommandEvent 介面的 command 只讀屬性返回一個字串,其中包含事件分派時 command 屬性的值。
CommandEvent
command
字串。
在下面的簡單示例中,我們設定了一個事件監聽器來監聽“show-modal”命令
document.body.addEventListener( "command", (event) => { const theAction = event.command; if (theAction === "show-modal") { console.log("Showing modal dialog"); } }, { capture: true }, );
載入中…
HTMLButtonElement.command
HTMLButtonElement.commandForElement