Latest

recent

JavaScript - The onselect event

Definition and Usage

The onselect event occurs when text is selected in a text or textarea field.

Syntax

onselect="SomeJavaScriptCode"

Parameter Description
SomeJavaScriptCode Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<input type="text">, <textarea>

Supported by the following JavaScript objects:

text, textarea


Example

In this example an alert box will be displayed if some of the text is selected:

<form>
Select text: <input type="text" value="Hello world!"
onselect="alert('You have selected some of the text.')">
<br /><br />
Select text: <textarea cols="20" rows="5"
onselect="alert('You have selected some of the text.')">
Hello world!</textarea>
</form>
JavaScript - The onselect event Reviewed by 1000sourcecodes on 04:03 Rating: 5
Powered by Blogger.