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();$(" ...

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

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

  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. 如何提高cocos2d-x-spine骨骼动画加载速度

    下面分2点来说: 1. 时间消耗点:io和现场解析 解决方案:加载过的骨骼动画就不要每次重新加载,不要每次都去加载json文件和atlas,我推荐使用 static CCSkeletonAnimati ...

  2. Java for LeetCode 174 Dungeon Game

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

  3. 给mysql数据库插入当前时间

    mysql相关的三个函数有: NOW()函数以`'YYYY-MM-DD HH:MM:SS'返回当前的日期时间,可以直接存到DATETIME字段中.CURDATE()以’YYYY-MM-DD’的格式返回 ...

  4. LightOJ 1315 - Game of Hyper Knights(博弈sg函数)

    G - Game of Hyper Knights Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & ...

  5. java操作AJAX

    1,get方式的AJAX function sendAjaxReq() { //1,创建ajax引擎 XMLHttpRequest对象 var req = new XMLHttpRequest() | ...

  6. Excel VBA Dir

    内容来自ExcelHome网站 一.题目: 要求编写一段代码,运用Dir函数返回一个文件夹的文件列表.二.代码:Sub 示例_1_12()        Dim wjm        wjm = Di ...

  7. 查看TOMCAT的版本

    [root@Apps bin]# sh version.sh Using CATALINA_BASE: /apps/api-tomcat Using CATALINA_HOME: /apps/api- ...

  8. MakeFile中赋值

    Makefile 中:= ?= += =的区别   在Makefile中我们经常看到 = := ?= +=这几个赋值运算符,那么他们有什么区别呢?我们来做个简单的实验 新建一个Makefile,内容为 ...

  9. Linux下可以替代windows的软件汇总:(不断完善中)

    http://www.ubuntukylin.com/ukylin/forum.php?mod=viewthread&tid=9530 原则:不求全面,只求实用.主要针对桌面级应用.网购:  ...

  10. 如何开启PostGreSQL的远程访问端口?

    用以下办法即可: postgresql默认情况下,远程访问不能成功,如果需要允许远程访问,需要修改两个配置文件,说明如下: 1.postgresql.conf 将该文件中的listen_address ...