代码示例:(标识:eg_js_events_onselect)
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "你选择了一些文字";
}
</script>
</head>
<body>

一些文本:<input type="text" value="Hello world!" onselect="myFunction()">

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

</body>
</html>
运行结果: