通过删除属性来启用和禁用按钮
这个问题在这里已经有了答案:
  使用.is(':checked')而不是欺骗价值。  也取代: 
$('#myButton').attr('disabled'); //Get the value
借:
$('#myButton').attr('disabled','disabled'); //Set the value
设置值。
  注意:你可以用prop()来代替: 
$("#myButton").prop('disabled', !$(this).is(':checked'));
希望这可以帮助。
  attr() / removeAttr()片段: 
$(document).ready(function(){
  $('#myCheckBox').on('change',function(){
    if( $(this).is(':checked') ){
      $('#myButton').removeAttr('disabled');
    }else{
      $('#myButton').attr('disabled','disabled');
    }
  });
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label for="myCheckBox">
  I agree with terms and conditions
  <input type="checkbox" id="myCheckBox" />
</label>
<br />
<br />
<input type="button" id="myButton" value="Submit" disabled />  你一直在想这个。  首先使用.prop()不是.attr() 。  其次,只需将禁用的属性设置为与复选框状态相反: 
  $('#myCheckBox').on('change', function() {
    $('#myButton').prop('disabled', !$(this).is(':checked'));
  })
$(document).ready(function() {
  $('#myCheckBox').on('change', function() {
    $('#myButton').prop('disabled', !$(this).is(':checked'));
  })
})<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label for="myCheckBox">
  I agree with terms and conditions
  <input type="checkbox" id="myCheckBox" />
</label>
<br />
<br />
<input type="button" id="myButton" value="Submit" disabled />  您不需要使用attr('value')而是使用this.checked来获取复选框状态。  然后使用prop()方法来设置按钮状态,如下所示。 
$('#myCheckBox').on('change', function() {
    $('#myButton').prop('disabled', !this.checked); 
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label for="myCheckBox">
  I agree with terms and conditions
  <input type="checkbox" id="myCheckBox" />
</label>
<br />
<br />
<input type="button" id="myButton" value="Submit" disabled />上一篇: Enable and disable button through remove attribute
下一篇: Disable a textarea field with name attribute using jquery
