HTMLButtonElement: commandForElement property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("Invoker Commands API")}}

The **commandForElement** property of the {{domxref("HTMLButtonElement")}} interface gets and sets the element to control via a button.

It is the JavaScript equivalent of the [commandfor](/en-US/docs/Web/HTML/Reference/Elements/button#commandfor) HTML attribute.

Value

A reference to an existing {{domxref("Element")}} that the button controls.

Examples

js
const popover = document.getElementById("mypopover");
const toggleBtn = document.getElementById("toggleBtn");

toggleBtn.commandForElement = popover;

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("Invoker Commands API", "Invoker Commands API", "", "nocode")}}
  • {{domxref("HTMLButtonElement.command")}}
  • {{domxref("CommandEvent")}}