编辑下面的代码:【加编码】
<html> <head> <script> function displayResult() { document.getElementById("orange").selected=true; } </script> </head> <body> <form> Select your favorite fruit: <select> <option id="apple">Apple</option> <option id="orange">Orange</option> <option id="pineapple" selected>Pineapple</option> <option id="banana">Banana</option> </select> </form> <button type="button" onclick="displayResult()">Select Orange</button> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂