"; this attribute is suitable for input, textarea and other tags."/> "; this attribute is suitable for input, textarea and other tags.">

Home  >  Article  >  Web Front-end  >  Does html have onchange event?

Does html have onchange event?

青灯夜游
青灯夜游Original
2021-09-13 14:30:113721browse

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

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!

Statement:
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