douyou7072
2014-01-30 07:46
浏览 42
已采纳

如果禁用主要主复选框,则禁用子复选框

enter image description here

what i want is when is when i click on My Repairs all the sub-checkboxes should be enabled.. if My Repairs is disabled the sub check boxes also has to disable..

<table id="tblId" width="500" height="700" border="0"  class="even" align="center" bgcolor="#E8F8FF">

  <tr>
    <td width="49">1
      <input name="row[]" type="checkbox" id="1" value="1" <?  echo in_array("1", $row)  ? "checked" : ''; ?>/>

   </td>
    <td colspan="3">Active Repairs</td>
  </tr>

   <tr>
    <td>2
      <input name="row[]" type="checkbox" id="2" value="2" <?  echo in_array("2", $row)  ? "checked" : ''; ?> onclick="enab();"/></td>
    <td colspan="3">My Repairs</td>
  </tr>
  <div id="darkLayer" class="darkClass" style="display:none">
  <tr>
  <td></td>
    <td >3
      <input name="row[]" type="checkbox" id="3" value="3" <?  echo in_array("3", $row)  ? "checked" : '';?> /></td>
    <td colspan="2">Active Calls</td>
  </tr>
</table>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dongliufa6380 2014-01-30 08:13
    最佳回答

    HTML

    <div>    
                 <input id="chkBlue" name="chkBlue" type="checkbox" value="blue" class="checkbox">Blue<br>  
               <input id="chkGreen" name="chkGreen" type="checkbox" value="green" class="checkbox" checked="true">Green
    </div>
    
    <div style="margin-left:20px;">           <input id="chkRed" name="chkMango" type="checkbox" value="Mango" class="checkbox2">Mango<br>
               <input id="chkBlue" name="chkOrange" type="checkbox" value="Orange" class="checkbox2">Orange<br>
               <input id="chkGreen" name="chkBanana" type="checkbox" value="Banana" class="checkbox2">Banana
          </div>
    

    Jquery

    $('#chkGreen').change(function () {              
       if( $('#chkGreen').prop('checked')==true)    
        $(".checkbox2").attr("disabled", true);
      else
           $(".checkbox2").attr("disabled", false);
                  });
    
       if( $('#chkGreen').prop('checked')==true)    
        $(".checkbox2").attr("disabled", true);
      else
           $(".checkbox2").attr("disabled", false);
    

    Demo

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题