javascript 获取select选中的option的值和文本

  1. 获得select选中的option的值:
var sel= document.getElementById('select');
var index = sel.selectedIndex; //序号,取当前选中选项的序号
var val = sel.options[index].value;
  1. 获得select选中的option的文本:
var sel = document.getElementById('mySelect');
var index = sel.selectedIndex; //序号,取当前选中选项的序号
var val = sel.options[index].text;

你可能感兴趣的:(javascript 获取select选中的option的值和文本)