onselect - 当输入文本被选取时

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function myFunction() {
  6. document.getElementById("demo").innerHTML = "你选择了一些文字";
  7. }
  8. </script>
  9. </head>
  10. <body>
  11.  
  12. 一些文本:<input type="text" value="Hello world!" onselect="myFunction()">
  13.  
  14. <p id="demo"></p>
  15.  
  16. </body>
  17. </html>