HTML onselect Event Attribute HTML Reference



Example

Execute a JavaScript after some text has been selected in an <input> element:

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

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

1. Definition and Usage

The onselect attribute fires after some text has been selected in an element.

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


2. Differences Between HTML 4.01 and HTML5

None.


3. Syntax

<element onselect="script">

4. Attribute Values

Value Description
script The script to be run on onselect

Relative articles