最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

淺析JQuery獲取和設(shè)置Select選項(xiàng)的常用方法總結(jié)

 更新時(shí)間:2013年07月04日 09:15:06   作者:  
本篇文章是對(duì)JQuery獲取和設(shè)置Select選項(xiàng)的一些常用方法進(jìn)行了匯總介紹,有需要的朋友可以參考一下

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項(xiàng)的個(gè)數(shù)
  
 $("#cusChildTypeId").get(0).options.length

5.設(shè)置select 選中的索引:
     $("#cusChildTypeId").get(0).selectedIndex=index;//index為索引值

6.設(shè)置select 選中的value:
    $("#cusChildTypeId").attr("value","Normal");
    $("#cusChildTypeId").val("Normal");
    $("#cusChildTypeId").get(0).value = "Normal";

7.設(shè)置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中添加一項(xiàng),顯示內(nèi)容為text,值為value
  
 $("#cusChildTypeId").get(0).options.add(new Option(text,value));

9.刪除select中值為value的項(xiàng)
        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;  

相關(guān)文章

最新評(píng)論

静海县| 巴东县| 江永县| 兴城市| 崇仁县| 水城县| 香格里拉县| 渝北区| 巨鹿县| 鸡东县| 筠连县| 黄石市| 镇赉县| 阜康市| 九江县| 屯留县| 海丰县| 法库县| 扶沟县| 白玉县| 高阳县| 高淳县| 浦城县| 平安县| 夏津县| 拜城县| 九龙城区| 封丘县| 衡东县| 青海省| 曲阜市| 许昌市| 海宁市| 大余县| 大同市| 育儿| 凤台县| 阿城市| 苏尼特右旗| 五华县| 金平|