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>