<html>
<body>
<p>Use the addEventListener() method to attach a "select" event to an input element.</p>
Select some text: <input type="text" value="Hello world!" id="myText">
<p id="demo"></p>
<script>
document.getElementById("myText").addEventListener("select", myFunction);
function myFunction() {
document.getElementById("demo").innerHTML = "You selected some text!";
}
</script>
</body>
</html>