Invoker commands
Limited availability
The command
and commandfor
attributes for the <button>
HTML element dispatch an action to an element when the button is invoked (by click or keystroke), as a declarative alternative to addEventListener()
calls or onclick
attribute handlers.
Learning resources on MDN
- CommandEvent
- CommandEvent: CommandEvent() constructor
- CommandEvent: command property
- CommandEvent: source property
- HTMLButtonElement: command property
- HTMLButtonElement: commandForElement property
- HTMLElement: command event
Browser support
- Chrome ❌
- Chrome Android ❌
- Edge ❌
- Firefox ❌
- Firefox for Android ❌
- Safari ❌
- Safari on iOS ❌
Specifications
- HTML (#attr-button-command), from HTML Workstream (WHATWG).
View web-platform-tests results for this feature - View the feature source file (dist) - Edit the feature - Report an issue about this feature