运行 ❯
获取您
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <p>Use the HTML DOM to assign an "onselect" 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").onselect = function() {myFunction()}; function myFunction() { document.getElementById("demo").innerHTML = "You selected some text!"; } </script> </body> </html>