Is there a way to hide checkboxes that aren't checked? I have three checkboxes and I'm looking for a way to hide the ones that aren't checked. The code I have now hides all checkboxes and I'm trying to hide the ones that aren't checked.
This is my code:
$('input[type=checkbox]').each(function ()
{
//Check if the box is checked
var x = $(this).is(':checked');
//if checkbox is NOT checked
if(x === false)
{
//Hide the choice
$(this).parent().hide();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="checkbox" name="testing" value="B">A</label><br />
<input type="checkbox" name="testing" value="I">B</label><br />
<input type="checkbox" name="testing" value="A">C</label><br />