源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <body> <p>在文本框中尝试输入触发函数。</p> <input type="text" id="myInput" oninput="myFunction()"> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myInput").value; document.getElementById("demo").innerHTML = "你输入的是: " + x; } </script> </body> </html>
运行结果: