更改被选选项

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function selectOrange()
  5. {
  6. document.getElementById("orange").selected=true;
  7. }
  8. </script>
  9. </head>
  10.  
  11. <body>
  12. <form>
  13. 请选择您喜欢的水果:
  14. <select>
  15. <option id="apple">苹果</option>
  16. <option id="orange">桔子</option>
  17. <option id="pineapple" selected="selected">菠萝</option>
  18. <option id="banana">香蕉</option>
  19. </select>
  20. <br /><br />
  21. <input type="button" onclick="selectOrange()" value="选择桔子">
  22. </form>
  23. </body>
  24. </html>