GeezerVison is showing developer.mozilla.org — HTMLButtonElement: commandForElement property - Web APIs | MDN
HTMLButtonElement: commandForElement property
Baseline 2025
Newly available
Since December 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
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.
A reference to an existing Element that the button controls.
js
const popover = document.getElementById("mypopover");
const toggleBtn = document.getElementById("toggleBtn");
toggleBtn.commandForElement = popover;