<div class="col-md-9"> <div class="box box-primary"> <div class="box-header with-border"> <h3 class="box-title">权限设置</h3> <!-- /.box-tools --> </div> <!-- /.box-header --> <div class="box-body"> <div class="mailbox-controls"> <div class="form-group"> <label> <input type="radio" name="allselect" value="1" class="minimal"> 全部选是 </label> <label> <input type="radio" name="allselect" value="0" class="minimal"> 全部选否 </label> </div> </div> <div class="table-responsive mailbox-messages"> <form class="js-form" action="" method="post" > <table class="table table-hover table-striped"> <tbody> <tr> <th>页面名称</th> <th>查看页面</th> <th>修改页面</th> <th>增加页面</th> <th>添加批注</th> </tr> <tr> <!-- <td><input type="checkbox"></td> --> <td>页面一</td> <td> <select class="form-control" name="read"> <option value="1">是</option> <option value="0">否</option> </select> </td> <td> <select class="form-control" name="modify"> <option value="0">否</option> <option value="1">是</option> </select> </td> <td> <select class="form-control" name="addpage"> <option value="0">否</option> <option value="1">是</option> </select> </td> <td> <select class="form-control" name="annotation"> <option value="0">否</option> <option value="1">是</option> </select> </td> </tr> <tr> <!-- <td><input type="checkbox"></td> --> <td>页面一</td> <td> <select class="form-control" name="read1"> <option value="1">是</option> <option value="0">否</option> </select> </td> <td> <select class="form-control" name="modify1"> <option value="0">否</option> <option value="1">是</option> </select> </td> <td> <select class="form-control" name="addpage1"> <option value="0">否</option> <option value="1">是</option> </select> </td> <td> <select class="form-control" name="annotation1"> <option value="0">否</option> <option value="1">是</option> </select> </td> </tr> </tbody> </table> <!-- /.table --> <a href="javascript:;" class="btn btn-primary btn-block margin-bottom">保存</a> </form> </div> <!-- /.mail-box-messages --> </div> <!-- /.box-body --> </div> </div>
$(function(){ $('input[name="allselect"]').change(function(){ var allvalue = $('input[name="allselect"]:checked').val(); //设置select中值为value的项为选中 if (allvalue == 0) { $(".js-form").find('select').each(function(){ $(this).get(0).value = 0; }) } else { $(".js-form").find('select').each(function(){ $(this).get(0).value = 1; }) } }) })