<input onselect="myFunction()"> - Javascript DOM Event

Javascript examples for DOM Event:onselect

Description

The onselect event occurs after some text has been selected in an element.

Summary

Bubbles No
Cancelable No
Supported HTML tags: <input type="file">, <input type="password">, <input type="text">, and <textarea>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Select some text: <input type="text" value="Hello world!" onselect="myFunction()">

<p id="demo"></p>

<script>
function myFunction() {//from   w  w  w.  ja v  a2s. com
    document.getElementById("demo").innerHTML = "You selected some text!";
}
</script>

</body>
</html>

Related Tutorials