x
 
<!DOCTYPE html>
<html>
<script>
function showMsg(){
    alert("你选中了一些文本");
}
</script>
<body>
<h1>HTML onselect 事件属性</h1>
<p>onselect 在 input 元素内的文本被选中后执行</p>
请尝试选择右边输入框的文字: <input type="text" value="Hello world!" onselect="showMsg()">
</body>
</html>