<span>编程语言:</span>
<select id="test" name="selectItem">
<option value="1">Java</option> <option value="2">PHP</option>
<option value="3">Android</option>
</select>
JQuery方法获取:
var language= $( '#test option:selected').val();
console.info(language);//例如选中Java,将输出:1
var languageText= $( '#test option:selected').text();
console.info(languageText);//例如选中PHP,将输出:PHP
JavaScript方法获取:
1:拿到select对象: var myselect=document.getElementById("test");
2:拿到选中项的索引:var index=myselect.selectedIndex ; // selectedIndex代表的是你所选中项的index
3:拿到选中项options的value: myselect.options[index].value;
4:拿到选中项options的text: myselect.options[index].text;