Home > Web Front-end > HTML Tutorial > The event attribute onclick triggered by a mouse click on an element in html

The event attribute onclick triggered by a mouse click on an element in html

黄舟
Release: 2017-11-06 09:46:51
Original
4551 people have browsed it

Example

Execute a piece of JavaScript when the button is clicked:

<button onclick="copyText()">Copy Text</button>
Copy after login

Browser support

IE

Firefox

Chrome

Safari

Opera

All major browsers support the onclick attribute.

Definition and Usage

The onclick attribute is triggered by a mouse click on the element.

Note: The onclick attribute does not apply to the following elements: , ,
, , ,