Hướng dẫn onclick trong html w3schools

Example

Execute a JavaScript when a button is clicked:

Try it Yourself »


Definition and Usage

The onclick event occurs when the user clicks on an element.


In JavaScript, using the addEventListener() method:

object.addEventListener("click", myScript);

Try it Yourself »



Technical Details

Bubbles:Yes
Cancelable:Yes
Event type:MouseEvent
Supported
HTML tags:
All exept: , ,
, , ,