jQuery addClass example
Change class name on click in jQuery
HTML
<input name="checkbox" type="checkbox" id="A" />A
<input name="checkbox" type="checkbox" id="B" />B
<input name="checkbox" type="checkbox" id="C" />C
<input name="checkbox" type="checkbox" id="D" />D
result: <span id=result>0</span>
<script>
$('input[name=checkbox]').click(function(){
var a = $('#A').prop("checked");
var b = $('#B').prop("checked");
var c = $('#C').prop("checked");
var d = $('#D').prop("checked");
var result = !a&d | a&!b | a&c&!d;
$('#result').text(result ? 1 : 0);
});
</script>