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 8880395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:09:33+00:00 2026-06-14T20:09:33+00:00

I am using JQuery cookie to change the color of a background. I also

  • 0

I am using JQuery cookie to change the color of a background. I also change logo images at the same time but on page reload, I am still trying to figure out how to get the cookie to retain the logo image. So far I have the background working with cookie but have not been able to figure out how to keep the selected theme logo image with cookie.

My code so far is:

<div class="main bg1"> 
<img id="logo-img" class="green-img" src="http://i1294.photobucket.com/albums/b601/danomatic11/logo-green.png" alt="logo"/>
<h2>Lorem ipsum dolor sit</h2>
</div>

<p>Choose a theme:</p>
<ul class="theme-switcher">
<li class="green">&nbsp;</li>
<li class="purple">&nbsp;</li>
<li class="rust">&nbsp;</li>
</ul>​

$("li.green").click( function(){ $
(".main").removeClass('bg2 , bg3').addClass("bg1");
$('#logo-img').attr('src', 'http://i1294.photobucket.com/albums/b601/danomatic11/logo-green.png');
$.cookie('mycookie','bg1');
$.cookie('mycookieimg','green-img');
});

etc…

As you can see I set a cookie on the background color when an <li> is clicked and the page is reloaded and I am trying to do the same for a logo image. It works so far as replacing the image on click but I cannot get the cookie to set right on page reload.

I have a Fiddle here.

  • 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-06-14T20:09:34+00:00Added an answer on June 14, 2026 at 8:09 pm

    Try this out….

    JSfiddle

       $(document).ready(function(){
    
    /* 
    On click the theme is changed for the image and the logo. So far I have JQuery cookie working to keep the background color that was selected even after page reload. 
    
    To do: retain the selected theme logo using coookie.
    */
    
    
        $("li.green").click( function(){ $
            (".main").removeClass('bg2 , bg3').addClass("bg1");
            $('#logo-img').attr('src', 'http://i1294.photobucket.com/albums/b601/danomatic11/logo-green.png');
            $.cookie('mycookie','bg1');
            $.cookie('mycookieimg','logo-green');
        });
    
        $("li.purple").click( function(){ $
            (".main").removeClass("bg1 , bg3").addClass("bg2");
            $('#logo-img').attr('src', 'http://i1294.photobucket.com/albums/b601/danomatic11/logo-purple.png');
            $.cookie('mycookie','bg2');
            $.cookie('mycookieimg','logo-purple');
        });
    
        $("li.rust").click( function(){ $
            (".main").removeClass("bg1 , bg2").addClass("bg3");
            $('#logo-img').attr('src', 'http://i1294.photobucket.com/albums/b601/danomatic11/logo-rust.png');
            $.cookie('mycookie','bg3');
            $.cookie('mycookieimg','logo-rust');
        }); 
    
        if ($.cookie('mycookie')) {
            var $imgsrc = $.cookie('mycookieimg');
            $('.main').addClass($.cookie('mycookie'));
            $('#logo-img').attr('src','http://i1294.photobucket.com/albums/b601/danomatic11/'+$imgsrc+'.png');
        }
    
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Jquery Cookie but am having difficulty setting and retrieving the info.
Using jquery, how can I change the color of these elements to red if
I am using the jQuery cookie plugin (also tried with EZCookie), I am stuck
i'm using the jquery cookie plugin. Everything works fine except the fact that I
I'm currently using jQuery Cookies plugin, and depending on which side of the page
Using Jquery TableSorter, I am creating a custom parser to sort elapsed time <td>
TLDR I need to change a javascript variable on the same page after clicking
I am using a cookie on my site to display colorbox one time on
im using jquery cookie to pass value of the element clicked on my first
I am currently using jquery.cookie to get/create cookies on a website; however, I am

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.