Jquery 选中所有复选框时启用p:commandlink按钮
在我的页面中,我有三个复选框,我想在选中所有复选框时启用提交按钮Jquery 选中所有复选框时启用p:commandlink按钮,jquery,jsf-2,Jquery,Jsf 2,在我的页面中,我有三个复选框,我想在选中所有复选框时启用提交按钮 <input type="checkbox" class="check" id="check1" /> <input type="checkbox" class="check" id="check2" /> <p:commandLink id="reviewLink" update="messages" ajax="false" action="${reviewBean.approveAndSubm
<input type="checkbox" class="check" id="check1" />
<input type="checkbox" class="check" id="check2" />
<p:commandLink id="reviewLink" update="messages" ajax="false" action="${reviewBean.approveAndSubmitWorkflow}" value="#msg['review.label.button.approve.submit']}"></p:commandLink>
您可以执行以下操作:
$("input.check").change(function(){
if ($('input.check:checked').length == $('input.check').length) {
$('#reviewLink').prop('disabled' , false);
}
});
**
这很简单
**
//禁用提交按钮
$(“#提交按钮”).attr('disabled','disabled');
//处理事件
$(“#check1,#check2,#check3”).live(“change”,function(){
//核对
如果($('check1')。是(':选中的')&&('check2')。是(':选中的')&('check3')。是(':选中的')){
$(“#提交按钮”).removeAttr('disabled');
}
})
此命令链接的等效HTML是什么?
if($( "input:checked").length==3){
$('#reviewLink').prop('disabled',false);
}
<input type="checkbox" class="check" id="check1" />
<input type="checkbox" class="check" id="check2" />
<input type="checkbox" class="check" id="check3" />
<script>
// Disable submit button
$("#submitButton").attr('disabled','disabled');
// Handle event
$("#check1, #check2, #check3").live("change",function(){
// Make a check
if ($('#check1').is(':checked') && $('#check2').is(':checked') && $('#check3').is(':checked')){
$("#submitButton").removeAttr('disabled');
}
})
</script>