fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <form> 选择你喜欢的浏览器: <select id="myList" onchange="myFunction()"> <option></option> <option>Google Chrome</option> <option>Firefox</option> <option>Internet Explorer</option> <option>Safari</option> <option>Opera</option> </select> <p>你喜欢的浏览器为: <input type="text" id="demo" size="20"></p> </form> <script> function myFunction() { var mylist = document.getElementById("myList"); document.getElementById("demo").value = mylist.options[mylist.selectedIndex].text; } </script> </body> </html>
运行结果