编辑下面的代码:【加编码】
<html> <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>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂