[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/API/HTMLButtonElement/command [Back]  [Original]

HTMLButtonElement: command - Web API | MDN

MDN Web Docs

View in English Always switch to English

HTMLButtonElement: command

Baseline 2025

202512

Experimental:

command HTMLButtonElement commandfor

HTML command

command

html
<button id="toggleBtn" commandfor="mypopover" command="toggle-popover">
  
</button>

<div popover id="mypopover">
  <button commandfor="mypopover" command="hide-popover">
    
  </button>
</div>
js
const popover = document.getElementById("mypopover");
const toggleBtn = document.getElementById("toggleBtn");

toggleBtn.command = "show-popover";

html
<button commandfor="the-image" command="--rotate-left"></button>

<button commandfor="the-image" command="--rotate-right"></button>

<img id="the-image" src="photo.jpg" alt="[]" />
js
const image = document.getElementById("the-image");

image.addEventListener("command", (event) => {
  if (event.command == "--rotate-left") {
    event.target.style.rotate = "-90deg";
  } else if (event.command == "--rotate-right") {
    event.target.style.rotate = "90deg";
  }
});

HTML
# dom-button-command


Web Proxy Viewer  |  New URL  |  Original Page