Hi,
How to check/uncheck checkboxes(Child) using a single(Parent) checkbox or vice-versa?
When i am using normal Html checkbox following code is working.
where Child and Parent are classes given to checkboxes.
$(".Parent").click(function () {
$(".Child").attr("checked", this.checked);
});
$(".Child").click(function(){
if($(".Child").length == $(".Child:checked").length) {
$(".Parent").attr("checked", "checked");
} else {
$(".Parent").removeAttr("checked");
}
});
But when i am using asp.net checkboxes this code is not working.
then i have modified the code as below.
$(".Parent:first-child").click(
function() {
$(".Child").find(":checkbox").attr("checked", this.checked);
});
$(".Child").find(":checkbox").click(function(){
if($(".Child").length == $(".Child:checked").length) {
$(".Parent").find(":checkbox").attr("checked", "checked");
} else {
$(".Parent").find(":checkbox").removeAttr("checked");
}
});
Is this Because of Span Rendering Problem?
How to Solve this Problem?
Thanks in Advance.