【发布时间】:2020-07-07 09:54:45
【问题描述】:
如果用户选中复选框,则应启用该按钮。如果没有,则应禁用按钮。
function test(){
if($(this).val() === true){ //not working
$('#send_button').prop('disabled', false);
}
else if($(this).val() === false){
$('#send_button').prop('disabled', true);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<input id="ischeck" type="checkbox" name="ischeck" value=true>
<label for="ischeck">ischeck</label><br>
<button id="send_button" class="btn btn-primary pull-right" onclick="test()">Send</button>
【问题讨论】:
-
这能回答你的问题吗? Setting "checked" for a checkbox with jQuery
标签: javascript html jquery button disable