JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<a href="http://jquery.com/">jQuery</a>
<?php
$env = "env"
<ul class="chk-container">
<li><input class="selecctall" type="checkbox"> Selecct All</li>
<li><input class="<?php echo $env;?>" type="checkbox" > This is Item 1</li>
<li><input class="checkbox1" type="checkbox" > This is Item 2</li>
<li><input class="checkbox1" type="checkbox" > This is Item 3</li>
<li><input class="checkbox1" type="checkbox" > This is Item 4</li>
<li><input class="checkbox1" type="checkbox" > This is Item 5</li>
<li><input class="checkbox1" type="checkbox" > This is Item 6</li>
<li><input class="checkbox2" type="checkbox" > Do not select this</li>
</ul>
</body>
</html>
JavaScript
$(document).ready(function() {
$('.selecctall').click(function(event) { //on click
if(this.checked) { // check select status
$('.env').each(function() { //loop through each checkbox
this.checked = true; //select all checkboxes with class "checkbox1"
});
}else{
$('.checkbox1').each(function() { //loop through each checkbox
this.checked = false; //deselect all checkboxes with class "checkbox1"
});
}
});
});