HTMLButtonElement: commandForElement property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
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
js
const popover = document.getElementById("mypopover");
const toggleBtn = document.getElementById("toggleBtn");
toggleBtn.commandForElement = popover;
Specifications
Specification |
---|
HTML # dom-button-commandforelement |
Browser compatibility
BCD tables only load in the browser