By using below code, if we check on one check box, all other check boxes will checked, if we un check all other check boxes will unchecked.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script language="javascript">
$('document').ready(function() {
$('#requestAccommodication').bind("click", doOperations);
});
var doOperations = (function () {
debugger;
if ($('#hai #requestAccommodication').is(':checked')) {
$("#hai input[type=checkbox]").each(function () {
$(this).prop("checked", true);
});
} else {
$("#hai input[type=checkbox]").each(function () {
$(this).prop("checked", false);
});
}
});
</script>
</head>
<body>
<div id="hai">
<input type="checkbox" id="requestAccommodication" /><br />
<input type='checkbox' name="1" id='isAccommadation_1' />JQuery
<input type='checkbox' name="2" id='isAccommadation_2' />Example
<input type='checkbox' name="3" id='isAccommadation_3' />Code
</div>
</body>
</html>
Post a Comment