SO - 31445771
by Simon Hartley
HTML
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>
<form>
<input type="checkbox" class="cbox1" id="cbox1"/><label for="cbox1">cbox1</label>
<input type="checkbox" class="cbox2" id="cbox2"/><label for="cbox2">cbox2</label>
<input type="checkbox" class="cbox3" id="cbox3"/><label for="cbox3">cbox3</label>
</form>
JavaScript
$(function () {
$('form').find('.cbox1, .cbox2, .cbox3').button();
$('form').each(function () {
var form = $(this);
form.find('.cbox1').change(function () {
if (form.find('.cbox1:checked').length) {
form.find('.cbox2, .cbox3').button("enable");
} else {
form.find('.cbox2, .cbox3')
.prop("checked", false)
.trigger("change")
.button("refresh")
.button("disable");
}
});
});
});