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.
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:
Modify the text and it will There is a pop-up prompt
#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!