zoukankan      html  css  js  c++  java
  • jquery 循环获取checkBox的值,以及对复选框选中,取消,操作按钮

    • 法一:jquery 循环获取选中checkBox框的值 
    • function checkeds() 
    • $("input:checkbox").each(function(index) 
    •    { 
    •        alert($("#checkid_"+index).val());//"#checkid_"+index  checkbox的id 
    •    }); 
    •  
    • 法二:jquery 循环获取选中checkBox框的值 
    • function checkeds(){  
    • //$('input:checkbox[name="multiple"]:checked')和$("input[name='multiple']:checked")是一样的效果 
    • $('input:checkbox[name="multiple"]:checked').each(function() //multiple checkbox的name 
    •    { 
    •         $(this).val(); 
    •    }); 
    •  
    • <input type="checkbox" id="checkid" name="multiple"class="input_w150" vili="true" onclick="checkeds()"/> 
    •  
    • <input type="checkbox" id="checkid" name="multiple"class="input_w150" vili="true" onclick="checkeds()"/> 
    •  
    •  
    •  
    • =====================第二部分================================= 
    •  
    • 1:进入页面时,按钮是置灰的,当选中复选框时将按钮设置成可以操作。 
    •  
    • <input type="checkbox" id="checkid" name="multiple"class="input_w150" vili="true" onclick="checkeds()"/>  
    •  
    • <input type="checkbox" id="checkid" name="multiple"class="input_w150" vili="true" onclick="checkeds()"/> 
    •  
    • <input type="button" value="ok" css="bc_submit" id="confirm_btn" disabled="true"
    •  
    •  
    •  
    • jquery代码: 
    •  
    •    function checks() 
    •    { 
    •       $("input:checkbox").each(function(index) 
    •       { 
    •      
    •           $("#checkid_"+index).click(function()  
    •           { 
    •           //获取当前被选中复选框的长度:$("input[id=checkid_"+index+"]:checked").length 
    •           //$("#checkid_"+index).attr("checked") == true 
    •                if($("input[name='multiple']:checked").length > 0)               { 
    •                     $('#confirm_btn').removeAttr('disabled'
    •                     return
    •                } 
    •                else 
    •                { 
    •                     $('#confirm_btn').attr('disabled','disabled'); 
    •                } 
    •           }); 
    •      }); 
    •   } 
  • 相关阅读:
    sqlserver服务 正在挂起更改,导致无法打开或者停止服务
    menuStrip与toolStrip的使用
    sqlDataCommandBuilder为dataGridView自动生成增删改代码时报错
    visual studio属性面板解释文字看不见
    窗体句柄 控件句柄
    form窗体show不出来
    TextBox密码框变文本框,文本框变密码框
    DataSet数据集手动添加一行记录
    Anaconda3-更换为清华源后依旧报错CondaHTTPError: HTTP 000 CONNECTION FAILED
    Kali Linux 国内源
  • 原文地址:https://www.cnblogs.com/ejllen/p/3622699.html
Copyright © 2011-2022 走看看