获取select被选中的option的值

<select id="select">
      <option>绥江</option>
      <option>西江</option>
      <option>北江</option>
      <option>贺江</option>
      <option>新兴江</option>
 </select>

 

$(function(){
        //jquery方法
        var options = $("#select option:selected");
        alert(options.val());
        alert(options.text());
        //js方法
        var selects = document.getElementById("select");
        var indexs = selects.selectedIndex;  //选中项的索引
        alert(selects.options[indexs].value);
        alert(selects.options[indexs].text);
    })

 弹窗结果

posted @ 2018-01-19 20:36  此地  阅读(28782)  评论(0编辑  收藏  举报