id 属性可设置或返回下拉列表的 id。
selectObject.id=id
下面的例子可返回下拉列表的 id:
<html>
<body>
<form id="myForm">
<select id="mySelect">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select>
</form>
<p>The id of the dropdown list is:
<script type="text/javascript">
document.write(document.getElementById("mySelect").id
)
</script>
</p>
</body>
</html>