简单教程
提交运行
代码编辑器:
<script> function displayResult(){ document.getElementById("orange").selected=true; } </script> <form> 选择你最喜欢的水果: <select> <option id="apple">Apple</option> <option id="orange">Orange</option> <option id="pineapple" selected="selected">Pineapple</option> <option id="banana">Banana</option> </select> </form> <button type="button" onclick="displayResult()">选择 Orange</button>
运行结果: