JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" name="box1" id="box1" onclick="function toggle('div1')">
<div id='div1'>
..div 1..
</div>

<input type="checkbox" name="box2" id="box2" onclick="function toggle('div2')">
<div id='div2'>
..div 2...
</div>

CSS

div { display: none; }

JavaScript

$.fn.toggleCheckboxDiv = function(div_id) {
   var thisDiv = $('#' + div_id);
   return $(this).each(function() {
      $(this).change(function() {
        $(this).is(':checked') ? thisDiv.show() : thisDiv.hide();
      });
   });
};

$(function() {
    $('#box1').toggleCheckboxDiv('div1');
    $('#box2').toggleCheckboxDiv('div2');
});