Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

onselect event

onselect event

Event Object Reference Event Object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the onselect event.


onselect in HTML

The onselect attribute can be used for: , , , , and LinkedHashMap, among others.


Event Object Reference Event Object