YouTip LogoYouTip

Event Onclick

## onclick Event ## Definition and Usage The onclick event occurs when the user clicks on an element. ## Browser Support | Event | !( | !( | !( | !( | !( | |-------|--------------------------------|-----------------------------|--------------------------------|----------------------------|---------------------------| | onclick | Yes | Yes | Yes | Yes | Yes | **Note:** The onclick event is supported by all major browsers. ## Syntax ```html ``` ## Attribute Values | Value | Description | |-------|-------------| | script | The script to be run when the mouse is clicked on the element | ## Technical Details | DOM Version | Level 2 DOM | |-------------|-------------| ## More Examples ### Example Alert "Hello World!" when clicking on a button: ```html function myFunction() { alert("Hello World!"); } ``` ### Example Using parameters: ```html function displayDate() { document.getElementById("demo").innerHTML = Date(); }

``` --- Click: times ## Related Pages HTML DOM reference: ( jQuery reference: ( Auspicious !(
← Event OndblclickMet Namednodemap Setnameditem β†’