A RetroSearch Logo

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

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/CommandEvent/source below:

CommandEvent: source property - Web APIs

CommandEvent: source property

Limited availability

The source read-only property of the CommandEvent interface returns an EventTarget representing the control that invoked the given command.

Value

An EventTarget object. Usually an HTMLButtonElement.

Examples

In the following simple example we've set up an event listener to add a temporary class to the button element upon a CommandEvent:

document.body.addEventListener(
  "command",
  (event) => {
    const theButton = event.source;

    theButton.classList.add("just-pressed");

    setTimeout(() => {
      theButton.classList.remove("just-pressed");
    }, 1000);
  },
  { capture: true },
);
Specifications Browser compatibility See also

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