Advertisement
Home Open Editor ❯

HTML onclick Attribute

Example

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

Try this code ❯

Meaning

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


Standard Syntax

<element onclick="script">


Applies to:

The onclick attribute can be used on the following element:

Element Attribute
All HTML elements onclick

Advertisement

Attribute Values

Value Description
script Specifies the script to be run on onclick
Home Open Editor ❯
Advertisement