<script type="text/javascript">
function showOptionId () {
var type = document.getElementById ("select"); //获取select
var typeId = type.options [type.selectedIndex].id; //获取option的ID
var typeValue = type.options [type.selectedIndex].innerText; //获取option的内容
alert ("ID:" +typeId + ", value:" + typeValue); //返回
}
</script>
<select id = "select" onchange = "showOptionId ()">
<option id = "id1" >海角孤星</option>
<option id = "id2" >http://www.jinyuanbao.cn</option>
<option id = "id3" >403033895</option>
<option id = "id4" >[email protected]</option>
<option id = "id5" >warewolf</option>
</select>
时间: 2024-11-08 15:21:59