JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" id="checkbox1" value="1" />
<div id="div1">Text to be toggled</div>

JavaScript

jQuery(function($) { // Shorter document ready namespace safer

  // initiate the state
  var checked = localStorage.getItem('checkbox1')
  if (checked) {
    $('#div1').hide()
    $('#checkbox1').prop('checked', true)
  }
  
  // Toggle the visibility
  $('#checkbox1').change(function() {
    $('#div1').toggle();
    this.checked 
      ? localStorage.setItem(this.id, true)
      : localStorage.removeItem(this.id)
  });
});