Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

HTMLButtonElement: Command Property

The article documents the `command` property of the `HTMLButtonElement` interface, which is experimental and allows a button to trigger an action defined by a `command` attribute linked to a `<command>` element or a built-in command.

Background

HTMLButtonElement — Command Property is part of the MDN (Mozilla Developer Network) documentation, a widely used reference for web developers. - This describes the `command` property on HTML button elements, part of the experimental "Invoker Commands" API (also called "command-for" or "command" attribute). - It lets a developer associate a button with a command to execute on another element (e.g., a `<button command="show-modal" commandfor="myDialog">` could open a dialog without JavaScript). - The goal is to reduce boilerplate JavaScript for common UI patterns like showing popovers, opening dialogs, or playing media. - As an experimental API, it's not yet supported in all browsers; MDN documentation helps developers track compatibility and syntax.