onselect event
Example
When text is selected, execute a piece of JavaScript code:
Try it »
Definition and Usage
The onselect event occurs when the text in a text field is selected.
Syntax
In HTML:
<
element
onselect="
SomeJavaScriptCode
">In JavaScript:
object
.onselect=function(){
SomeJavaScriptCode
}
| Parameters | Description |
|---|---|
| SomeJavaScriptCode | Required. Specifies the JavaScript to be executed when the event occurs. |
Browser support





All major browsers support the onselect event.
onselect in HTML
The onselect attribute can be used for: , , ,
Event Object