Me pregunto que todo el mundo ha publicado acerca valuey textopción para llegar desde <option>y nadie sugerido label.
Así que también estoy sugiriendo label, compatible con todos los navegadores
Para obtener value(igual que otros sugirieron)
function test(a) {
var x = a.options[a.selectedIndex].value;
alert(x);
}
Para obtener option text(es decir, comunicación o -Seleccionar-)
function test(a) {
var x = a.options[a.selectedIndex].text;
alert(x);
}
O (nueva sugerencia)
function test(a) {
var x = a.options[a.selectedIndex].label;
alert(x);
}
HTML
<select onchange="test(this)" id="select_id">
<option value="0">-Select-</option>
<option value="1">Communication</option>
<option value="2" label=‘newText’>Communication</option>
</select>
Nota: En HTML anterior para el optionvalor 2, labeldevolverá newText en lugar de Communication
también
Nota: No es posible establecer la propiedad de la etiqueta en Firefox (solo retorno).