简单教程
提交运行
代码编辑器:
<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>
运行结果: