Invoker Commands API
The commandForElement property of the HTMLButtonElement interface gets and sets the element to control via a button.
It is the JavaScript equivalent of the commandfor HTML attribute.
Value
A reference to an existing Element that the button controls.
Examples
const popover = document.getElementById("mypopover");
const toggleBtn = document.getElementById("toggleBtn");
toggleBtn.commandForElement = popover;
Specifications
Browser compatibility
See also
- Invoker Commands API
- HTMLButtonElement.command
- CommandEvent
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
