简单教程
提交运行
代码编辑器:
<script> function displayResult(){ alert(document.getElementById("mySelect").length); } </script> <form> <select id="mySelect"> <option>Apple</option> <option>Pear</option> <option>Banana</option> <option>Orange</option> </select> </form> <button type="button" onclick="displayResult()">下拉列表中有多少选项?</button>
运行结果: