Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Need help with Cookies! (Jquery)

    So I have this script that flips between 3 views (3 different backgrounds) and I want to use cookies to make it remember the last chosen background.

    Code:
    <script type="text/javascript">
    
        $(document).ready(function(){
    
        $("a.switch_thumb").toggle(function(){
            $(this).addClass("swap");
            $(".main").fadeOut("fast", function() {
                $(this).fadeIn(300).addClass("main2");
            });
        }, function () {
            $(this).addClass("swap");
            $(".main2").fadeOut("fast", function() {
                $(this).fadeIn(300).addClass("main3");
            });
    
        }, function () {
            $(this).removeClass("swap");
            $(".main").fadeOut("fast", function() {
                $(this).fadeIn(300).removeClass("main3");
        $(this).fadeIn(300).removeClass("main2");
            });
        });
    
    </script>
    Can anyone help me with it?
    Thanks in advance!

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You need to set a cookie when a selection is made, and retrieve the stored cookie when the page is loaded. This page walks you through both processes.

    http://w3schools.com/js/js_cookies.asp

  • Users who have thanked Fumigator for this post:

    UNEXE (09-10-2010)

  • #3
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    You need to set a cookie when a selection is made, and retrieve the stored cookie when the page is loaded. This page walks you through both processes.

    http://w3schools.com/js/js_cookies.asp
    Thanks so much!
    But I'm kinda new to Jquery, and I can't really get it to work, is there any chance you can help me edit the code?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •