Get to know MDN better
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.
| HTML # dom-button-commandforelement |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 14, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.