function
getSelectval(id){ var selId = document.getElementById(id); //获取select的id var seleIndex =selId.selectedIndex; //获取被选项的引索值 alert(selId.options[seleIndex].value); //获取被选项的value
    alert(selId.options[seleIndex].text); //获取被选项的文本 }

 
<select id="sel" onchange="getSelectval('sel')">
        <option selected value="1">val1</option>
        <option value="2">val2</option>
        <option value="3">val3</option>
    </select>

 

 

相关文章:

  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2022-03-08
猜你喜欢
  • 2021-10-24
  • 2021-08-04
  • 2021-10-20
  • 2021-12-12
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案