JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods
Arrays

JAVASCRIPT ONSELECT EVENT

The javascript onselect event handler is used to trigger a script or action when a user selects some text in a text field. The onselect event calls the action from the <input> or <textarea> element.

Example:

<form action="#" method="post" >
<textarea onselect="alert('You have selected some text');"></textarea><br>
<input type="submit" value="submit" >
</form>

The above example will output You have selected some text when you select text.

The onselect event can also call a function as follows:

<head>

<script type="text/javascript">

function selectme ()
{
alert('You have selected some text');
}
</script>

</head>

<body>

<form action="#" method="post" >
<textarea onselect="selectme();"></textarea><br>
<input type="submit" value="submit" >
</form>

DEMO:

Enter some text and then select it in the form below to see the effect.



See also:

onload
onunload
onclick
ondblclick
onmousedown
onmouseup
onmouseover
onmousemove
onmouseout
onkeypress
onkeydown
onkeyup
onfocus
onblur
onsubmit
onreset
onchange


Home | Privacy Policy | Terms Of Use | Contact Us