HTML onselectEvent Attributes

HTML 事件属性HTML Event Attributes

Examples

Execute JavaScript after selecting text in the <input> element:

<input type="text" onselect="showMsg() value="Hello world!">

Try it yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the onselect event attribute.


Definition and Usage

The onselect attribute is triggered after an element's text is selected.

The onselect attribute can be used on the following elements: <input type="file">, <input type="password">, <input type="text">, <keygen>, and <textarea>.


Differences between HTML 4.01 and HTML5

None.


Syntax

<element onselect="script">

Attribute value

Value Description
script Specifies the script to be executed when the onselect event is triggered.


HTML 事件属性HTML Event Attributes Other extensions