国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
jquery操作select
  1. //得到select項的個數(shù)     
  2. jQuery.fn.size = function(){     
  3.     return jQuery(this).get(0).options.length;     
  4. }     
  5.   
  6. //獲得選中項的索引     
  7. jQuery.fn.getSelectedIndex = function(){     
  8.     return jQuery(this).get(0).selectedIndex;     
  9. }     
  10.   
  11. //獲得當(dāng)前選中項的文本     
  12. jQuery.fn.getSelectedText = function(){     
  13.     if(this.size() == 0return "下拉框中無選項";     
  14.     else{     
  15.         var index = this.getSelectedIndex();           
  16.         return jQuery(this).get(0).options[index].text;     
  17.     }     
  18. }     
  19.   
  20. //獲得當(dāng)前選中項的值     
  21. jQuery.fn.getSelectedValue = function(){     
  22.     if(this.size() == 0)      
  23.         return "下拉框中無選中值";     
  24.          
  25.     else  
  26.         return jQuery(this).val();     
  27. }     
  28.   
  29. //設(shè)置select中值為value的項為選中     
  30. jQuery.fn.setSelectedValue = function(value){     
  31.     jQuery(this).get(0).value = value;     
  32. }     
  33.   
  34. //設(shè)置select中文本為text的第一項被選中     
  35. jQuery.fn.setSelectedText = function(text)     
  36. {     
  37.     var isExist = false;     
  38.     var count = this.size();     
  39.     for(var i=0;i<count;i++)     
  40.     {     
  41.         if(jQuery(this).get(0).options[i].text == text)     
  42.         {     
  43.             jQuery(this).get(0).options[i].selected = true;     
  44.             isExist = true;     
  45.             break;     
  46.         }     
  47.     }     
  48.     if(!isExist)     
  49.     {     
  50.         alert("下拉框中不存在該項");     
  51.     }     
  52. }     
  53. //設(shè)置選中指定索引項     
  54. jQuery.fn.setSelectedIndex = function(index)     
  55. {     
  56.     var count = this.size();         
  57.     if(index >= count || index < 0)     
  58.     {     
  59.         alert("選中項索引超出范圍");     
  60.     }     
  61.     else  
  62.     {     
  63.         jQuery(this).get(0).selectedIndex = index;     
  64.     }     
  65. }     
  66. //判斷select項中是否存在值為value的項     
  67. jQuery.fn.isExistItem = function(value)     
  68. {     
  69.     var isExist = false;     
  70.     var count = this.size();     
  71.     for(var i=0;i<count;i++)     
  72.     {     
  73.         if(jQuery(this).get(0).options[i].value == value)     
  74.         {     
  75.             isExist = true;     
  76.             break;     
  77.         }     
  78.     }     
  79.     return isExist;     
  80. }     
  81. //向select中添加一項,顯示內(nèi)容為text,值為value,如果該項值已存在,則提示     
  82. jQuery.fn.addOption = function(text,value)     
  83. {     
  84.     if(this.isExistItem(value))     
  85.     {     
  86.         alert("待添加項的值已存在");     
  87.     }     
  88.     else  
  89.     {     
  90.         jQuery(this).get(0).options.add(new Option(text,value));     
  91.     }     
  92. }     
  93. //刪除select中值為value的項,如果該項不存在,則提示     
  94. jQuery.fn.removeItem = function(value)     
  95. {         
  96.     if(this.isExistItem(value))     
  97.     {     
  98.         var count = this.size();             
  99.         for(var i=0;i<count;i++)     
  100.         {     
  101.             if(jQuery(this).get(0).options[i].value == value)     
  102.             {     
  103.                 jQuery(this).get(0).remove(i);     
  104.                 break;     
  105.             }     
  106.         }             
  107.     }     
  108.     else  
  109.     {     
  110.         alert("待刪除的項不存在!");     
  111.     }     
  112. }     
  113. //刪除select中指定索引的項     
  114. jQuery.fn.removeIndex = function(index)     
  115. {     
  116.     var count = this.size();     
  117.     if(index >= count || index < 0)     
  118.     {     
  119.         alert("待刪除項索引超出范圍");     
  120.     }     
  121.     else  
  122.     {     
  123.         jQuery(this).get(0).remove(index);     
  124.     }     
  125. }     
  126. //刪除select中選定的項     
  127. jQuery.fn.removeSelected = function()     
  128. {     
  129.     var index = this.getSelectedIndex();     
  130.     this.removeIndex(index);     
  131. }     
  132. //清除select中的所有項     
  133. jQuery.fn.clearAll = function()     
  134. {     
  135.     jQuery(this).get(0).options.length = 0;     
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
jquery的each()詳細介紹
jquery 將json對象賦值給form表單
jquery 獲取頁面url,并根據(jù)url模擬單擊事件
css(name|pro|[,val|fn]) | jQuery API 1.12 中文文檔 | jQuery API 在線手冊
我最喜歡的jQuery插件模板
js常用方法之事件注冊
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服