jscookie show/hide content with jquery display block-none not worked

55 Views Asked by At

Need show-hide content and set cookie, and read cookie - if=1 show, if=0 hide my content) ACCORDION with jsCOOKIE CONTENT not worked ) hard math for me pls helps, i thinks its easy.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/3.0.1/js.cookie.min.js" type="text/javascript"></script>

jQuery(document).ready(function(){

  var cookie = Cookies.get('activePanelGroup');
   $("#hideshow").click(function(){

    if(cookie == 1){
       $('#content').show();
       Cookies.remove('activePanelGroup');
       Cookies.set('activePanelGroup', '0', {expires:7});
    }
    if(cookie == 0){
       $('#content').hide();
       Cookies.remove('activePanelGroup');
       Cookies.set('activePanelGroup', '0', {expires:7});
    }
    console.log(Cookies.get('activePanelGroup')); 
    cookie = 1;
   });

 <div id="hideshow">THIS HIDE SHOW BUTTON</div>

 <div id="content">ACCORDION COOKIE CONTENT<BR>CONTENT</div>
0

There are 0 best solutions below