HTMLButtonElement: commandForElement プロパティ

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

commandForElementHTMLButtonElement インターフェイスのプロパティで、ボタンを通じて制御する要素を取得または設定します。

これは JavaScript における HTML の commandfor 属性の同等物です。

このボタンが制御する既存の要素 (Element) への参照です。

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

toggleBtn.commandForElement = popover;

仕様書

Specification
HTML
# dom-button-commandforelement

ブラウザーの互換性

BCD tables only load in the browser

関連情報