HTML onclick Attribute

❮ HTML Attributes


<button onclick="myFunction()">Click me</button>


The onclick attribute specifies the script run a mouse click on the element.

Standard Syntax

<element onclick="script">

Browser Support


Applies to:

The onclick attribute can be used on the following element:

Element Attribute
All HTML elements onclick

Attribute Values

Value Description
script Specifies the script to be run on onclick
❮ HTML Attributes