Execute a JavaScript when a button is clicked:
![]()
The onclick event attribute is supported in all major browsers.
The onclick attribute fires on a mouse click on the element.
Note: The onclick attribute CANNOT be used with: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, or <title>.
None.
| Value | Description |
|---|---|
| script | The script to be run on onclick |
HTML Event Attributes
Your message has been sent to W3Schools.