HTML DOM type 属性

定义和用法

type 属性可返回下拉列表的表单类型。对于下拉列表,类型总是 "select-one" 或 "select-multiple"。

语法

  1. selectObject.type

实例

下面的例子返回下拉列表的表单类型:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function getType()
  5. {
  6. alert(document.getElementById("mySelect").type)
  7. }
  8. </script>
  9. </head>
  10. <body>
  11.  
  12. <form>
  13. <select id="mySelect">
  14. <option>Apple</option>
  15. <option>Pear</option>
  16. <option>Banana</option>
  17. <option>Orange</option>
  18. </select>
  19. <input type="button" onclick="getType()"
  20. value="Alert type of dropdown list">
  21. </form>
  22. </body>
  23. </html>