Home > Web Front-end > HTML Tutorial > What does onclick mean in html5

What does onclick mean in html5

WBOY
Release: 2021-12-22 11:01:26
Original
11701 people have browsed it

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">

What does onclick mean in html5

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">
Copy after login

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>
Copy after login

Output result:

What does onclick mean in html5

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template