JavaScript获取Select当前值写法:
var valor = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;
var text = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].text;
Exemplo:
复制代码代码如下:
<roteiro>
verificação de função() {
var select = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;
alerta(selecione);
}
</script>
<select name="selecionar" id="selecionar">
<option value="test1" selecionado="selected">Teste1</option>
<option value="test2">Teste2</option>
</selecionar>
<input type="button" value="我要试试" onclick="check()"/>