addEventListener("select", myFunction); - Javascript DOM Event

Javascript examples for DOM Event:addEventListener

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!" id="myText">

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

<script>
document.getElementById("myText").addEventListener("select", myFunction);

function myFunction() {/*from  w  w  w . j a  v a 2s.  c  om*/
    document.getElementById("demo").innerHTML = "You selected some text!";
}
</script>

</body>
</html>

Related Tutorials