HTML onchangeEvent Attribute

HTML 事件属性HTML Event Attributes

Examples

Run a script when the element changes:

<input type="text" name="txt" value="Hello" onchange="checkField(this.value)">

Try it yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the onchange event attribute


Definition and Usage

The onchange attribute triggers when the element value changes.

The onchange attribute applies to <input>, <textarea>, and <select> elements.


Differences between HTML 4.01 and HTML5

None.


Syntax

<element onchange="script">

Attribute Values

Value Description
script Specifies the script to be executed when the onchange event fires.


HTML 事件属性HTML Event Attributes Other Extensions