jQuery:仅单击所有复选框时如何启用按钮? [英] jQuery: How to enable button when only all check boxes are clicked?
本文介绍了jQuery:仅单击所有复选框时如何启用按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当所有复选框都被选中时,如何启用按钮"?
How to enable the "button" when all check boxes are clicked?
例如:
<form action="">
<input type="checkbox" class="checkbox" id="button1" />
<input type="checkbox" class="checkbox" id="button2" />
<input type="checkbox" class="checkbox" id="button3" />
<input type="submit" value="Checkout" id="submitbutton" disabled="disabled"/>
</form>
推荐答案
$(function(){
// on change event
var bool;
$("input.checkbox").change(function() {
bool = $(".checkbox:not(:checked)").length !=0;
// enable/disable
$("#submitbutton").prop('disabled', bool);
})
});
DEMO
这篇关于jQuery:仅单击所有复选框时如何启用按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文