Onselect event In Java Script

This event gets fired when user selects text in a textbox or text field. A text field contains text and we can select that text but when we select text of a text field onselect event gets fired.
 
Example:
 
<html>

<head>

<title>events </title>

</head>

<body bgcolor=blue text=”white” >

<form name=”sandeep” onselect=”alert(‘hi’)”>

Name : <input type=”text” name=t1 id=”tt1″ > <br>

Address : <input type=”text” name=t2 > <br>

Educational Qualification :

<select>

<option> 10th

<option> 12th

<option> Graduate

<option> Post Graduate

<option> PhD

</select><br>

Comments :<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<textarea rows=5 onselect=”alert(‘yes delete this selected text’)”>

You can type this text and type your comments here

</textarea>

</form>

<script>

function ff()

{

alert(“The value being set is ” +document.all.tt1.value)

}

</script>

</body>

</html>

Scroll to Top