A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/de/docs/Web/API/HTMLButtonElement/command below:

HTMLButtonElement: command Eigenschaft - Web-APIs

HTMLButtonElement: command Eigenschaft

Limited availability

Die command-Eigenschaft des HTMLButtonElement-Interfaces ruft die Aktion ab, die auf einem von dieser Schaltfläche gesteuerten Element ausgeführt werden soll, und setzt diese. Damit dies Wirkung zeigt, muss commandfor gesetzt sein.

Sie spiegelt das HTML-Attribut command wider.

Wert

Ein String. Siehe das command-Attribut für gültige Werte.

Beispiele Einfaches Beispiel
<button id="toggleBtn" commandfor="mypopover" command="toggle-popover">
  Toggle popover
</button>

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

toggleBtn.command = "show-popover";
Benutzerdefiniertes Beispiel unter Verwendung von Ereignissen
<button commandfor="the-image" command="--rotate-left">Rotate Left</button>

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

<img id="the-image" src="photo.jpg" alt="[add appropriate alt text here]" />
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";
  }
});
Spezifikationen Browser-Kompatibilität Siehe auch MDN-Feedback-Box War diese Übersetzung hilfreich?

Diese Seite wurde automatisch aus dem Englischen übersetzt.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4