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. 提取http接口响应报文中需要的值,获得的是string,使用dict转换为字典处理

  2. p1313计算系数题解

    #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #i ...

  3. Python脱产8期 Day06 2019/4/18

    一 深浅拷贝 例:ls = [1, 'abc', [10]] 1.值拷贝:s1 = ls    # ls1直接将ls中存放的地址拿过来,>ls内部的值发生任何变化,ls1都会随之变化. 2.浅拷 ...

  4. AI LeNet

    LeNet 参考链接: http://yann.lecun.com/exdb/publis/pdf/lecun-01a.pdf https://www.charleychai.com/blogs/20 ...

  5. 使用 OAuth2-Server-php 搭建 OAuth2 Server

    Yii 有很多 extension 可以使用,在查看了 Yii 官网上提供的与 OAuth 相关的扩展后,发现了几个 OAuth2 的客户端扩展,但是并没有找到可以作为 OAuth2 Server 的 ...

  6. Spring Cloud 分布式链路跟踪 Sleuth + Zipkin + Elasticsearch【Finchley 版】

    随着业务越来越复杂,系统也随之进行各种拆分,特别是随着微服务架构的兴起,看似一个简单的应用,后台可能很多服务在支撑:一个请求可能需要多个服务的调用:当请求迟缓或不可用时,无法得知是哪个微服务引起的,这 ...

  7. Volley使用

    Volley是常用的网络请求框架,主要的用法如下: 获取字符串: public static void volleyTest1(final Context context){ RequestQueue ...

  8. 【愚人节快乐】拥抱Bootstrap,FineUI新版效果超炫!

    鉴于 Bootstrap 备受欢迎,我们决定用 Bootstrap 完全替换掉 jQuery,得到了更加漂亮的界面,先睹为快: 注:网页背景图片来自百度网盘,版权归百度所有! 详情:http://fi ...

  9. Java之所有输入流输出流的分类

    (1)字节输入流        基类:InputStream        FileInputStream.ByteArrayInputStream.PipedInputStream.Buffered ...

  10. Taro、Weex、Hippy 齐聚IMWebConf 2018!

    IMWebConf 2018 前端大会,10 月 14 日重磅来袭! 想了解 2018 前端前沿技术和发展趋势?想挖掘前端更深远的价值?就在这个秋季,第七届 IMWebConf 大会重磅来袭,我们邀请 ...