HTML event attribute onselect








The onselect attribute event is triggered after selecting text in an element.

What's new in HTML5

None.

Syntax

<elementName onselect="script">

Supported Tags

<input type="file">, 
<input type="password">, 
<input type="text">, 
<keygen>, 
<textarea>




Browser compatibility

onselect Yes Yes Yes Yes Yes

Example

<!DOCTYPE html>
<html>
<body>
<!-- www.  j a v a2s  .  co m-->
Some text: <input type="text" value="Select me!!" onselect="myFunction()">

<script>
function myFunction() {
    console.log("You have selected some text!");
}
</script>

</body>
</html>

Click to view the demo