Hi,歡迎訪問前端老白
<select> <option value="item1">選項1</option> <option value="item2">選項2</option> <option value="item3">選項3</option> </select>
<style> select { color: blue; background-color: gray; } </style>
<select size="3"> <option value="item1">選項1</option> <option value="item2">選項2</option> <option value="item3">選項3</option> </select>
<script> function showItem() { var index = document.querySelector('select').selectedIndex; var selectedValue = document.querySelector('select').options[index].value; window.alert('您選擇的是:' + selectedValue); } </script> <select onchange="showItem()"> <option value="item1">選項1</option> <option value="item2">選項2</option> <option value="item3">選項3</option> </select>
老白網絡 (http://www.lofty888.cn/) 前端 后端 zblog主題.網站地圖xml