HTML onselect event attribute
Example
Execute a JavaScript when the text inside the <input> element is selected:
<input type="text" onselect="showMsg()" value="Hello world!">
Browser Support
IE | Firefox | Chrome | Safari | Opera |
---|---|---|---|---|
All major browsers support the onselect attribute.
Definition and Usage
The onselect attribute triggers when the text in the element is selected.
The onselect attribute can be used within 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 | Script that runs when onselect occurs. |