"."/> ".">
Home >Web Front-end >HTML Tutorial >What does onclick mean in html5
Onclick in html5 means "click". The onclick attribute is a type of mouse event, which is triggered when the mouse is clicked. It is used to specify the script to be executed when the event is triggered. The syntax is "<element onclick="script">". <element onclick="script">
The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.
#What does onclick mean in html5
onclick is an attribute of the HTML tag object.
The onclick attribute is a type of mouse event, which is triggered when the mouse is clicked.
The onclick attribute cannot be applied to the following elements:
, , ,
The syntax is as follows:
<element onclick="script">
where script indicates the script that is specified to be executed when the onclick event is triggered.
The example is as follows:
<html> <head> <meta charset="utf-8"> <title>123</title> <script> function copyText() { document.getElementById("field2").value=document.getElementById("field1").value; } </script> </head> <body> 字段1: <input type="text" id="field1" value="Hello World!"><br> 字段2: <input type="text" id="field2"> <br><br> <button onclick="copyText()">复制文本</button> <p>在按钮点击时触发函数。函数将字段1的文字信息复制到字段2。</p> </body> </html>
Output result:
Recommended tutorial: "html video tutorial"
The above is the detailed content of What does onclick mean in html5. For more information, please follow other related articles on the PHP Chinese website!