<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);
    })

弹窗结果

获取select被选中的option的值的更多相关文章

  1. JS获取select被选中的option的值

    一:JavaScript原生的方法 1:拿到select对象: var myselect=document.getElementById(“test”); 2:拿到选中项的索引:var index=m ...

  2. js获取select默认选中的Option (非当前选中值)

    js函数方法: <script> function getDefaultSelectedOption(selectId, valIfNull) { var selectId = selec ...

  3. JS动态获取select中被选中的option的值,并在控制台输出

    生活城市: <select id="province"> <option>河南省</option> <option>黑龙江省< ...

  4. 获取select标签选中状态 的label的值。

    <select name="procode" onchange="alert(this.options[this.selectedIndex].text)" ...

  5. jq获取被选中的option的值。jq获取被选中的单选按钮radio的值。

    温故而知新,一起复习下jq的知识点. (1) jq获取被选中的option的值 <select id="select_id"> <option value=&qu ...

  6. 获取select标签选中的值

    js获取select标签选中的值 var obj = document.getElementById(”testSelect”); var index = obj.selectedIndex; var ...

  7. JavaScript获取Select下拉框Option的Value和Text值的方法

    Js获取select下拉列表框各个Option的Value值相对比较容易,不过获取Text值却有点麻烦,对于一个初学JavaScript的 新手来说,可能一时还无从下手,那么就请看下本文的方法,以一个 ...

  8. JQuery 获取select被选中的value和text

    html代码: <select name="test" > <option value="0">请选择</option> & ...

  9. JS中如何获取<Select>中value和text的值

    原文地址:JS中如何获取<Select>中value和text的值 html代码: <select id = "city" onchange="chan ...

随机推荐

  1. 将 context node 中的内容 分配给 desing layer

    1 将 context node 中的内容 分配给 desing layer 选中context node 右键>assignment to design layer.

  2. 282A

    #include <iostream> #include <string> using namespace std; int main() { int n, plus, sub ...

  3. jode反编译软件

    1.下载 http://jode.sourceforge.net/(官网) https://sourceforge.net/projects/jode/files/(下载地址) 2.使用 下载的jod ...

  4. docker容器多服务(不推荐)

    1.最常用方式配置进程管理工具Supervisor 2.最简单的就是把多个启动命令放到一个启动脚本里面,启动的时候直接启动这个脚本 第一种方式: 1.构建基础镜像 FROM lmurawsk/pyth ...

  5. Java通过sftp上传文件

    Linux操作系统我们经常使用ssh中的ftp,sftp连接服务器,做相应操作. 如何通过java代码的形式采用sftp连接到服务器,进行文件上传下载等操作呢? 第一步,引入依赖包 <!-- s ...

  6. pycharm tips

    批量更改变量名,就在该变量名上shift+f6 ../data 两个点,就是上一级目录,一个点就是当前目录 unhashable type: 'list' 使用set进行去重 a = [1,2,2,3 ...

  7. 【LeetCode每天一题】Rotate Image(旋转矩阵)

    You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise). N ...

  8. es6 数组..... ==和===的区别 es6的递归方式 es6find函数 timer setTimeout v-html的用法,-

    相当于push了  find函数来找到某个值 如果新建一个 setTimeout 的timer 首先得清除这个timer. v-html用法之一就是加载后台传过来的模板

  9. element后太侧边

    $router 是已经在ruterJs里面定义好的路由 以及组件 然后取值赋予进去就是了.但是真正的写法应该是 这样,, 执行点击事件的时候直接让跟换路由., 让后面 router-view 里面路由 ...

  10. pandas.query()

    1. 查询 已知data: 查询概率等于0.4的所有行 问题所在:query后面只支持string形式的值,而"probability"==0.4返回的是一个bool类型,结果不是 ...