陪你做好前端设计!
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>素材8网教程(study.sucai8.cn)</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>
运行结果