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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:18:32+00:00 2026-06-14T07:18:32+00:00

I’m trying to make a stylesheet switcher in jquery with a success but when

  • 0

I’m trying to make a stylesheet switcher in jquery with a success but when I try to save the changes in a cookie using jquery.cookie plugin, it doesnt work..

here’s the jquery code:

$("#theme-cp ul li").click(function () {
    var $pattern = $(this).css("background-image");
    $("body").css("background-image",$pattern);
    $("#main-wrapper").css("background-image",$pattern);
    $.cookie('background',$pattern);
    alert($.cookie('background'));
});

the alert is for a check but it doesnt work….

  • 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-14T07:18:34+00:00Added an answer on June 14, 2026 at 7:18 am

    I have recently done the same thing, i got it working, thought i’d share my code with you.

    jsFiddle

    jQuery

    //If Cookie isn't blank (i.e. do we have a cookie set at all?)
    if($.cookie('colour')!='')
    {
        $('body').addClass($.cookie('colour'));  //set the body to the cookie colour
    }
    
    $('#accessibility-colours a').each(function(index)
    {
        $(this).click(function(e)
        {
            e.preventDefault();
    
            switch(index)
            {
                //black text white background
                case 0:
                    $('body').removeClass($.cookie('colour'));
                    $('body').addClass('blackText-whiteBackground');
                    $.cookie('colour', null);
                    $.cookie('colour', 'blackText-whiteBackground',{ expires: 7, path: '/' });
                break;
    
                //black text yellow background
                case 1:
                    $('body').removeClass($.cookie('colour'));
                    $('body').addClass('blackText-yellowBackground');
                    $.cookie('colour', null);
                    $.cookie('colour', 'blackText-yellowBackground',{ expires: 7, path: '/' });
                break;
    
                //black text pink background
                case 2:
                    $('body').removeClass($.cookie('colour'));
                    $('body').addClass('blackText-pinkBackground');
                    $.cookie('colour', null);
                    $.cookie('colour', 'blackText-pinkBackground',{ expires: 7, path: '/' });
                break;
    
                //blue text white background
                case 3:
                    $('body').removeClass($.cookie('colour'));
                    $('body').addClass('blueText-whiteBackground');
                    $.cookie('colour', null);
                    $.cookie('colour', 'blueText-whiteBackground',{ expires: 7, path: '/' });
                break;
    
            }
        });
    

    CSS

    html, body                              {font:0.9em/1.1em "Arial", sans-serif}
    
    /* Accesibility Icons */
    #accessibility-colours                  {margin:0px; overflow:hidden;}
    #accessibility-blackWhite               {background:url(../images/design/icon-accessibility-blackWhite.gif) 0 0 no-repeat}
    #accessibility-blackYellow              {background:url(../images/design/icon-accessibility-blackYellow.gif) 0 0 no-repeat}
    #accessibility-blackPink                {background:url(../images/design/icon-accessibility-blackPink.gif) 0 0 no-repeat}
    #accessibility-blueWhite                {background:url(../images/design/icon-accessibility-blueWhite.gif) 0 0 no-repeat}
    
        #accessibility-colours a            {float:left; display:block; margin:6px 0 0; padding:4px; border:0; width:16px; height:16px;}
        #accessibility-colours a span       {margin:0; padding:0; position:absolute; top:-9999px; left:-9999px;}
    
    
    /* Colours to be set for accessibility choice */
    .blackText-whiteBackground              {background:white; color:black}
    .blackText-yellowBackground             {background:yellow; color:black}
    .blackText-pinkBackground               {background:pink; color:black}
    .blueText-whiteBackground               {background:white; color:blue}
    

    HTML

    <div id="accessibility-colours">
            <a id="accessibility-blackWhite" href="#" title="Black text / White background"><span>Black text / White background</span></a>
            <a id="accessibility-blackYellow" href="#" title="Black text / Yellow background"><span>Black text / Yellow background</span></a>
            <a id="accessibility-blackPink" href="#" title="Black text / Pink background"><span>Black text / Pink background</span></a>
            <a id="accessibility-blueWhite" href="#" title="Blue text / White background"><span>Blue text / White background</span></a>
        </div>
    
        <h1>This is the H1 tag</h1>
    
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam facilisis nibh sed tortor blandit interdum semper leo ullamcorper. 
        Pellentesque gravida hendrerit accumsan. Mauris pretium blandit augue, suscipit ultricies libero aliquam sit amet. Aliquam egestas eleifend augue, 
        et hendrerit dolor dictum facilisis. Nulla facilisi. Integer auctor elementum purus id lobortis. Aliquam sit amet sem erat. Integer nec orci risus. 
        Quisque eu purus augue. Sed vehicula venenatis metus eget molestie. Proin vel ultrices augue. Duis in laoreet tellus. Proin eget gravida purus. 
        Donec ut placerat velit. Etiam ultrices, nibh nec ultricies iaculis, odio orci porta dui, quis semper nunc ante interdum augue. 
        Curabitur elementum orci interdum nibh adipiscing blandit. Curabitur diam arcu, semper id facilisis id, tempor et nisi. 
        Vestibulum nisl dolor, aliquam et posuere ut, tincidunt sed mi.</p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:

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.