Easy Tutorial
❮ Met Element Hasattribute Coll Doc Scripts ❯

onclick Event

Event Object

Example

Execute JavaScript code when a button is clicked:


Definition and Usage

The onclick event occurs when an element is clicked.

Syntax

In HTML:

In JavaScript:

Parameter Description
SomeJavaScriptCode Required. The JavaScript to be executed when the event occurs.

Browser Support

All major browsers support the onclick event.


HTML Tags Supported by the onclick Event:

The onclick attribute can be used with all HTML elements except: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>.


❮ Met Element Hasattribute Coll Doc Scripts ❯