单击

时间:2017-02-24 10:36:26

标签: jquery

我使用下面的代码取消选中单击单选按钮上的所有复选框,但当我尝试再次选中复选框时,我必须双击而不是单击选择

if(($('#radAllBaxDocs').is(':checked')) || ($('#radLabels').is(':checked')){
    $('.sol-checkbox').each(function(){this.checked = false;});
}

1 个答案:

答案 0 :(得分:0)

请您尝试.prop取消选中Checkbox ...如下面的代码

$('#radAllBaxDocs, #radLabels').change(function(){
  if($('#radAllBaxDocs, #radLabels').is(':checked'))
  {
    $('.sol-checkbox').prop("checked",false);
  }
 
 });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="radio" id="radAllBaxDocs" name="1" > Hello
<input type="radio" id="radLabels" name="1"> Hello

<input type="checkbox" value="Hello" class="sol-checkbox">1
<input type="checkbox" value="Hello" class="sol-checkbox">2
<input type="checkbox" value="Hello" class="sol-checkbox">3
<input type="checkbox" value="Hello" class="sol-checkbox">4
<input type="checkbox" value="Hello" class="sol-checkbox">5