Hello.
When you select the desired checkbox, a class is assigned to all labels at once, but only to the one you want. When pressed again, the class is not deleted.
With any selection, a .block-all block is .block-all , but when you click on checkbox again (to close all blocks), this block does not close.
Please help me correct the errors. Thank!

 $("#block-box input[type='checkbox']").click(function(){ $(".blocks").hide(); $("#block-box input[type='checkbox']").not(this).each(function(){ $("#block-box label").removeClass("label_active"); $(".block-all").hide(); this.checked = false; }); if (this.checked) $("." + $(this).data("blockclass")).show(); $("#block-box label").addClass("label_active"); $(".block-all").show(); }); 
 .block-ru, .block-ua, .block-all { display: none; } .label_active { color: red; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="block-box"> <label class="label_ru"><input type="checkbox" name="ru" id="ru" value="1" data-blockclass="block-ru">Россия</label> <label class="label_ua"><input type="checkbox" name="ua" id="ua" value="1" data-blockclass="block-ua">Украина</label> </div> <div class="blocks block-ru">Выбор России</div> <div class="blocks block-ua">Выбор Украины</div> <div class="blocks block-all">Показ при любом выборе</div> 

    1 answer 1

     $("#block-box input[type='checkbox']").click(function(){ // hide and deactivate everything $(".blocks").hide(); $(".block-all").hide(); $("#block-box label").removeClass("label_active"); // uncheck all other checkboxes $("#block-box input[type='checkbox']").not(this).each(function(){ this.checked = false; }); // show/activate things for this checkbox, if it is checked if (this.checked) { $("." + $(this).data("blockclass")).show(); $(this).closest("label").addClass("label_active"); $(".block-all").show(); } }); 
     .block-ru, .block-ua, .block-all { display: none; } .label_active { color: red; } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="block-box"> <label class="label_ru"><input type="checkbox" name="ru" id="ru" value="1" data-blockclass="block-ru">Россия</label> <label class="label_ua"><input type="checkbox" name="ua" id="ua" value="1" data-blockclass="block-ua">Украина</label> </div> <div class="blocks block-ru">Выбор России</div> <div class="blocks block-ua">Выбор Украины</div> <div class="blocks block-all">Показ при любом выборе</div> 

    • Igor, hello. Yes, I understood how to. Thank you, good luck! - LADYX