Home >Web Front-end >HTML Tutorial >html event attribute onchange triggered when element value changes

html event attribute onchange triggered when element value changes

黄舟
黄舟Original
2018-05-15 10:13:125980browse

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

html event attribute onchange triggered when element value changeshtml event attribute onchange triggered when element value changes##

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!

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