onselect = myFunction(); - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

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").onselect = function() {myFunction()};

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

</body>
</html>

Related Tutorials