JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<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
$.cookie('state', 'closed');
// 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;
});