jquery获取select选择的文本与值
获取select :
获取select 选中的 text :
    $("#ddlregtype").find("option:selected").text();

获取select选中的 value:
    $("#ddlregtype ").val();

获取select选中的索引:
    $("#ddlregtype ").get(0).selectedindex;

设置select:
设置select 选中的索引:
    $("#ddlregtype ").get(0).selectedindex=index;//index为索引值

设置select 选中的value:
    $("#ddlregtype ").attr("value","normal“);
    $("#ddlregtype ").val("normal");
    $("#ddlregtype ").get(0).value = value;

设置select 选中的text:

var count=$("#ddlregtype option").length;
      for(var i=0;i<count;i++)
         {           if($("#ddlregtype ").get(0).options[i].text == text)
            {
                $("#ddlregtype ").get(0).options[i].selected = true;
                break;
            }
        }
    $("#select_id option[text='jquery']").attr("selected", true);

设置select option项:

$("#select_id").append("<option value='value'>text</option>");  //添加一项option
    $("#select_id").prepend("<option value='0'>请选择</option>"); //在前面插入一项option
    $("#select_id option:last").remove(); //删除索引值最大的option
    $("#select_id option[index='0']").remove();//删除索引值为0的option
    $("#select_id option[value='3']").remove(); //删除值为3的option
    $("#select_id option[text='4']").remove(); //删除text值为4的option

清空 select:

$("#ddlregtype ").empty();

jquery获取select选择的文本与值的更多相关文章

  1. Jquery获取select选中的文本与值

    jquery获取select选择的文本与值获取select :获取select 选中的 text :    $("#ddlregtype").find("option:s ...

  2. jQuery取得select选择的文本与值

    jquery获取select选择的文本与值获取select :获取select 选中的 text :$("#ddlregtype").find("option:selec ...

  3. [荐] jQuery取得select选择的文本与值

    csdn:http://blog.csdn.net/tiemufeng1122/article/details/44154571 jquery获取select选择的文本与值获取select :获取se ...

  4. js&jquery 获取select下拉框的值、文本内容、自定义属性

      js&jquery 获取select下拉框的值.文本内容.自定义属性 CreationTime--2018年7月2日09点22分 Author:Marydon html <selec ...

  5. Jquery获取select,dropdownlist,checkbox下拉列表框的值

       jQuery获取 Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...});   ...

  6. jQuery获取Select选择的Text和 Value(转)用时比较方便寻找

    ---恢复内容开始--- jQuery获取Select选择的Text和Value:语法解释:1. $("#select_id").change(function(){//code. ...

  7. jQuery获取Select选择的Text和 Value(转)

    radio: radio: var item = $('input[name=items][checked]').val(); var item = $('input[name=items]:chec ...

  8. jQuery获取Select选择的Text和 Value

    jQuery获取Select选择的Text和Value:语法解释:1. $("#select_id").change(function(){//code...});   //为Se ...

  9. jQuery获取Select选择的Text(非表单元素)和 Value(表单元素)(转)

    jQuery获取Select选择的Text和Value: 语法解释: . $("#select_id").change(function(){//code...}); //为Sel ...

随机推荐

  1. Flask路由报错:raise FormDataRoutingRedirect(request)

    raise FormDataRoutingRedirect(request)FormDataRoutingRedirect: A request was sent to this URL (http: ...

  2. jenkins使用3----相关工具安装

    一.相关工具安装 a.git安装 #yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc-c++ ...

  3. 典型分布式系统分析:Bigtable

    本文是典型分布式系统分析的第三篇,分析的是Bigtable,一个结构化的分布式存储系统. Bigtable作为一个分布式存储系统,和其他分布式系统一样,需要保证可扩展.高可用与高性能.与此同时,Big ...

  4. Linux 修改时间和时区为上海时区

    发现centos7的时间是utc的,和上海时间不一样. 由于/usr/share/zoneinfo/Asia/  这个目录下没有北京时区,就选择了上海时区,只要赋值过去就可以了 rm -f /etc/ ...

  5. 朱晔和你聊Spring系列S1E1:聊聊Spring家族的几大件

    朱晔和你聊Spring系列S1E1:聊聊Spring家族的几大件 [下载本文PDF进行阅读] Spring家族很庞大,从最早先出现的服务于企业级程序开发的Core.安全方面的Security.到后来的 ...

  6. 1、Django系列之web应用与http协议

    第1节:最简单的web应用程序 Web应用程序指供浏览器访问的程序,通常也简称为Web应用.应用程序有两种模式C/S.B/S.C/S是客户端/服务器端程序,也就是说这类程序一般独立运行.而B/S就是浏 ...

  7. Sql Server中的nvarchar(n)、varchar(n) 和Mysql中的char(n)、varchar(n)

    刚才有幸看了下 nvarchar(n)和varchar(n),感觉以前的认知有误. nvarchar(n):n指的是字符个数,范围是1-4000,存储的是可变长度的Unicode字符数据. 按字符存储 ...

  8. 爱奇艺2017秋招笔试(C++智能设备方向)

    虽然有方向,但是好像题目都是随机题库抽取. 选择题都很基础...挖坑,待更新 编程: 一. 奇异数: 如果一个数字满足以下条件,我们就称它为奇异数: 1.   这个数字至少有两位 2. 这个数的最低两 ...

  9. Python_每日习题_0004_一年中的第几天

    # 题目 输入某年某月某日,判断这一天是这一年的第几天? # 程序分析 特殊情况,闰年时需考虑二月多加一天: def isLeapYear(y): return (y%400==0 or (y%4== ...

  10. BZOJ1283 序列 网络流区间覆盖模型

    就是区间覆盖模型的费用流版. 区间覆盖模型