html中select的用法
话不多说.直接附demo,简单明了:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <html> 2 3 <head> 4 5 <script type="text/javascript"> 6 function test(){ 7 var obj = document.getElementById("s"); 8 var index=obj.selectedIndex; 9 var val = obj.options[index].value; 10 var val2 = obj.options[index].text; 11 12 alert(val + ":" + val2); 13 } 14 </script> 15 </head> 16 17 <body> 18 sex: 19 <select id="s"> 20 <option value="1"></option> 21 <option value="2">male</option> 22 <option value="3">female</option> 23 </select> 24 <input type="button" value="testSelect" onclick=test()> 25 </body> 26 27 </html>