view image description hereLet's create a checkbox structure with some specific conditions:
- When the parent checkbox is selected, all child checkboxes should automatically get selected.
- If all child checkboxes are unselected, then the parent checkbox should also get unchecked automatically.
- If any single child checkbox is selected, the parent checkbox should get selected as well.
This is how the structure should appear:
Below is my code. However, it doesn't seem to meet the second condition perfectly. The logic seems correct but there might be a syntax issue. Kindly point out the necessary changes or corrections needed. Thank you in advance!
<!DOCTYPE html>
<html>
<head>
<title>jquery3</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script src="#"></script>
. . .
</body>
</html>