Firefox Tomorrow

web api instance property

HTMLButtonElement: commandForElement property

View on MDN ↗

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

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also