JSFiddle - React, Tailwind, and code Playground

HTML

<div id="toolo"> 
text 1
 <button id="hide">Open</button>           
</div>
	

 <div id="toolo2">
     text 2
    <button id="show">Hide</button>
</div>

JavaScript

// onload js

// if open div cookie
 if($.cookie('state') == 'open'){
         $("#toolo").show();
         $("#toolo2").hide();
      } 
// if close div cookie
else if ($.cookie('state') == 'closed') {
      $("#toolo").hide();
        $("#toolo2").show();
      } 

else {  
    $("#toolo2").hide();  
}


// hide button 
  $("#hide").click(function(){
        $("#toolo").hide();
        $("#toolo2").show();
$.cookie('state', 'open', { expires:3 });
 return false;

    });

// show button
   $("#show").click(function(){
        $("#toolo").show();
         $("#toolo2").hide();
       
$.cookie('state', 'closed', { expires:3 })
 return false;

    });