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