获取包含下拉列表的表单的 id

  1. <html>
  2. <body>
  3.  
  4. <form id="myForm">
  5. <select id="mySelect">
  6. <option>Apple</option>
  7. <option>Pear</option>
  8. <option>Banana</option>
  9. <option>Orange</option>
  10. </select>
  11. </form>
  12.  
  13. <p>这个下拉列表的 id 是:
  14. <script type="text/javascript">
  15. document.write(document.getElementById("mySelect").id)
  16. </script>
  17. </p>
  18.  
  19. </body>
  20. </html>