• 法一: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');
  • }
  • });
  • });
  • }