1.获取select 选中的 text:
 $("#cusChildTypeId").find("option:selected").text();
 $("#cusChildTypeId option:selected").text()

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

3.获取select选中的索引:
      $("#ddlRegType ").get(0).selectedIndex;

4.得到select项的个数  
 $("#cusChildTypeId").get(0).options.length

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

6.设置select 选中的value:
    $("#cusChildTypeId").attr("value","Normal");
    $("#cusChildTypeId").val("Normal");
    $("#cusChildTypeId").get(0).value = "Normal";

7.设置select 选中的text:
 1>.var count=$("#cusChildTypeId").get(0).options.length;
     for(var i=0;i<count;i++) 
         {          
  if($("#cusChildTypeId").get(0).options.text == text) 
         { 
             $("#cusChildTypeId").get(0).options.selected = true;
             break; 
         } 
        }

2>.$("#cusChildTypeId").val(text);
    $("#cusChildTypeId").change();

8.向select中添加一项,显示内容为text,值为value  
 $("#cusChildTypeId").get(0).options.add(new Option(text,value));

9.删除select中值为value的项
        var count = $("#cusChildTypeId").size();          
        for(var i=0;i<count;i++)  
        {  
            if($("#cusChildTypeId").get(0).options[i].value == value)  
            {  
                $("#cusChildTypeId").get(0).remove(i);  
                break;  
            }
        }

10.清空 Select:
 1>. $("#cusChildTypeId").empty();
 2>. $("#cusChildTypeId").get(0).options.length = 0;

JQuery获取和设置Select选项的常用方法总结的更多相关文章

  1. JQuery获取和设置Select选项常用方法总结 (转)

    1.获取select 选中的 text: $("#cusChildTypeId").find("option:selected").text(); $(&quo ...

  2. JQuery获取和设置Select选项常用方法总结

    1.获取select 选中的 text: $("#cusChildTypeId").find("option:selected").text(); $(&quo ...

  3. jquery 获取和设置Select选项常用方法总结

    1.获取select 选中的 text:$("#cusChildTypeId").find("option:selected").text();$(" ...

  4. jquery 获取和设置 select下拉框的值(转手册)

    ##实例应用中遇到的问题 //在某事件响应的应用中设置select选中项,前两种情况的设置不生效,使用了最后一种用法才生效的 //$("#select_time").find(&q ...

  5. jquery 获取和设置 select下拉框的值

    获取Select : 获取select 选中的 text : $("#ddlRegType").find("option:selected").text(); ...

  6. JQuery获取和设置select下拉框的值

    获取Select : 获取select 选中的 text : $("#sid").find("option:selected").text(); 获取selec ...

  7. JQuery获取与设置select

    获取select : 1.获取select 选中的 text :    $("#ddlregtype").find("option:selected").tex ...

  8. jquery获取和设置元素高度宽度

    jquery获取和设置元素高度宽度 1.height()/ width() 取得第一个匹配元素当前计算的高度/宽度值(px) height(val)/ width(val) 为每个匹配的元素设置CSS ...

  9. JQuery获取与设置HTML元素的值value

    JQuery获取与设置HTML元素的值value 作者:简明现代魔法图书馆 发布时间:2011-07-07 10:16:13 20481 次阅读 服务器君一共花费了13.221 ms进行了6次数据库查 ...

随机推荐

  1. bzoj 2164: 采矿

    Description 浩浩荡荡的cg大军发现了一座矿产资源极其丰富的城市,他们打算在这座城市实施新的采矿战略.这个城市可以看成一棵有n个节点的有根树,我们把每个节点用1到n的整数编号.为了方便起见, ...

  2. [转]Supporting OData Query Options in ASP.NET Web API 2

    本文转自:https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/suppor ...

  3. 浅谈MES系统SMT的JIT功能(二):JIT流程

    上周说到JIT的原理,今天就说说JIT功能的基本流程:从维护基本信息——>生产人员排程——>仓库人员发料——>生产上料——>JIT物料配送看板拉到仓库人员发第二次料,循环上料发 ...

  4. 关于webApi使用session

    1.关于webApi使用session 在Global.asax中注册session添加以下代码 public override void Init() { //开启session this.Post ...

  5. RabbitMQ - exchange

    总结一下几种ExchangeTypes. 之前写发布/订阅模式时第一次提到了exchange type.即producer不是将消息直接放到队列中,而是先到exchange中,exchange主要用于 ...

  6. MySql 学习(一)

    入门使用 show databases; //假设存在seckill 数据库 use seckill; //查看所有表 show tables; //查看某个表的字段,例如存在 student 表 d ...

  7. .net IoC 之 Spring.Net 适合刚开始使用

    Spring.Net包括控制反转(IoC) 和面向切面(AOP),这篇文章主要说下IoC方面的入门. 一.首先建立一个MVC项目名称叫SpringDemo,然后用NuGet下载spring(我用的是S ...

  8. [android] 标题部分管理

    标题分类 1.1 普通标题 1.1.1 标题内容管理 1.1.2 帮助和返回的按钮 1.2 未登录的标题 1.3 登陆中的标题 1.4 登陆完成后的标题 package com.tsh.lottery ...

  9. js分离html代码的body内外部分

    //定义网页源码 str = '<!DOCTYPE html><html><head> <meta charset="UTF-8"> ...

  10. Linux 安装 EPEL YUM源

    原文:https://blog.csdn.net/harbor1981/article/details/51135623 我们用yum安装软件时,经常发现我们的yum源里面没有该软件,需要自己去wge ...