Example
Check the input field when the value changes:
<input type="text" name="txt" value="Hello" onchange="checkField(this.value)">
Browser support
IE
Firefox
Chrome
Safari
Opera
All major browsers support onchange attribute.
Definition and usage
onchange is triggered when the element value changes.
The onchange attribute applies to: ,
Differences between HTML 4.01 and HTML5
None.
Syntax
<element onchange="script">
Attribute value
Value | Description |
script | Script to run when onchange occurs. |
Example
Check the input field when the value changes:
<input type="text" name="txt" value="Hello" onchange="checkField(this.value)">
请修改输入字段中的文本,然后在字段外点击以触发 onchange。
请输入文本:<input type="text" name="txt" value="Hello" onchange="checkField(this.value)">
##
The above is the detailed content of html event attribute onchange triggered when element value changes. For more information, please follow other related articles on the PHP Chinese website!