JSFiddle - React, Tailwind, and code Playground

by s4ty

HTML

<input id="strom_checkbox" type="checkbox" />
<div id="strom_content">
    <input type="textbox"/>
    <input type="textbox"/>
    <input type="textbox"/>
    <input type="textbox"/>
    <input type="textbox"/>
</div>

CSS

#strom_content{
    display: none;
    width: 600px;
    height: 200px;
    border: 1px solid black;
}

JavaScript

$('#strom_checkbox').change(function() {
    if($(this).is(":checked")){
        $('#strom_content').show();
        
    } else {
        var clear = true;
        $('#strom_content input').each( function (){
            if($(this).val().length > 0) { 
                clear = false; 
                return false;
            }
            clear = true;
            
        })
        if(clear) {
            $('#strom_content').hide();
        } else {
            $(this).attr('checked', 'checked');
        }
        
    }
})