简单教程
提交运行
代码编辑器:
<script> function displayResult(){ alert(document.getElementById("mySelect").name); } </script> <form> <select name="mySelect" id="mySelect"> <option>Apple</option> <option>Pear</option> <option>Banana</option> <option>Orange</option> </select> </form> <button type="button" onclick="displayResult()">显示下拉列表的名称</button>
运行结果: