Does html have onchange event?

青灯夜游
Release: 2023-01-11 09:19:49
Original
3725 people have browsed it

There is an onchange event in HTML. You can set the onchange event by adding the onchange event attribute to the label. The syntax is ""; this attribute is suitable for input, textarea and other tags.

Does html have onchange event?

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

There is an onchange event in html, which is triggered when the element value changes.

In HTML, you can set the onchange event by adding the onchange event attribute to the label.

The onchange attribute applies to: ,

Syntax:

<element onchange="script">
Copy after login
  • script: The script that runs when onchange occurs.

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<script>
function checkField(val)
{
	alert("输入值已改变。新值为: " + val);
}
</script>
</head>
<body>

<p>修改输入域的文本,点击输入域外区域触发 onchange。</p>
输入文本: <input type="text" name="txt" value="Hello" onchange="checkField(this.value)">

</body>
</html>
Copy after login

Rendering:

Does html have onchange event?

Modify the text and it will There is a pop-up prompt

Does html have onchange event?

#For more programming-related knowledge, please visit: Programming Video! !

The above is the detailed content of Does html have onchange event?. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!