Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7568645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:58:39+00:00 2026-05-30T14:58:39+00:00

Why is this not saving the cookie when you refresh the page? http://jsfiddle.net/jBVBL/ Or

  • 0

Why is this not saving the cookie when you refresh the page?

http://jsfiddle.net/jBVBL/

Or would it be better practice to save only 1 cookie with the value of every li with “.active”

var hideshow = $(".hideShow");

hideshow.children().not(".active").each(function(index, value){
    var tis = $(this);

    if($.cookie('hideShow_id'+index) == index){
        tis.addClass(".active");
    } else {
        $(this).find("div").hide();
    }            
});

hideshow.find('h3').click(function(e){
    var tis = $(this);
    var tisindex= tis.parents("li").index;
        $.cookie('hideShow_id' + tisindex, tisindex);

        tis.next().slideToggle('2000');
        tis.parent().toggleClass('active');
    e.preventDefault();
});


<ul class="hideShow">
        <li class="active">
         <h3><a href="javascript:;">Pellentesque nec leo cursus ipsum rhoncus volutpat nec eget mi.</a></h3>
         <div>
               <p>Nam velit metus, vulputate eget sodales ut, dignissim vehicula nisi. Lorem ipsum dolor sit amet</p>
             <ul>
                 <li>
                     <strong>Pellentesque</strong> nec leo cursus ipsum rhoncus volutpat nec eget mi.</li>
                 <li>

                     <strong>Nam</strong> quis lectus enim, ac euismod urna.</li>
                 <li>
                     <strong>Donec</strong> varius massa augue, at feugiat tortor.</li>
             </ul>
         </div>
    </li>
    <li>
     <h3><a href="javascript:;">Pellentesque nec leo cursus ipsum rhoncus volutpat nec eget mi.</a></h3>
     <div>
           <p>Nam velit metus, vulputate eget sodales ut, dignissim vehicula nisi. Lorem ipsum dolor sit amet</p>
         <ul>
             <li>
                 <strong>Pellentesque</strong> nec leo cursus ipsum rhoncus volutpat nec eget mi.</li>
             <li>

                 <strong>Nam</strong> quis lectus enim, ac euismod urna.</li>
             <li>
                 <strong>Donec</strong> varius massa augue, at feugiat tortor.</li>
         </ul>
     </div>
    </li>
    <li>
     <h3><a href="javascript:;">Pellentesque nec leo cursus ipsum rhoncus volutpat nec eget mi.</a></h3>
     <div>
           <p>Nam velit metus, vulputate eget sodales ut, dignissim vehicula nisi. Lorem ipsum dolor sit amet</p>
         <ul>
             <li>
                 <strong>Pellentesque</strong> nec leo cursus ipsum rhoncus volutpat nec eget mi.</li>
             <li>

                 <strong>Nam</strong> quis lectus enim, ac euismod urna.</li>

         </ul>
     </div>
    </li>
</ul> 

Using: https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:58:40+00:00Added an answer on May 30, 2026 at 2:58 pm

    You are creating a different cookie for each index, and they never match the one you look for on page load. In addition, you have different cookie name strings ‘hideShow-id’ vs ‘hideShow_id’

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Java application is saving stuff in 'user.home' but on windows this does not
I ask this not to start anything negative. Rather, after looking at ASP.NET MVC
I save a cookie in a sharepoint webpart in this way: System.Web.HttpCookie cookie =
Does anyone see a problem with this, its not working saying bad file descriptor
Let me start by saying that I do not advocate this approach, but I
For some reason this program is saying that 'switch' is not defined. What is
So let me preface this by saying that I'm not an SQL wizard by
I will preface this question by saying, I do not think it is solvable.
Let me start out by saying that I'm not a JavaScript developer so this
Sorry for this not being a real question, but Sometime back i remember seeing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.