The onclick event attribute in HTML works when the user clicks on the button. When the mouse clicked on the element then the script runs.
Syntax: <element onlick = "script">
Attribute Value: This attribute contains a single value script that works when the mouse clicked on the element.