tags:

views:

797

answers:

2

i want to make a body background switcher using jquery. you will have some buttons and each will change the body bg according to your choice. and i want to make it so like that it will save a cookie so that it can retrieve user's choice when you change the page.

first part i got it useing .addclass or .css but i am stuck on the svaing user's choice part.

(sorry for my english)

+3  A: 

Have a look at this article which should help you with saving/retreiving and delteing cookies:

http://www.quirksmode.org/js/cookies.html

Pim Jager
+3  A: 

Also have a look at the Cookie plugin for jQuery, which allows you to do stuff like this:

$.cookie('the_cookie', 'the_value'); // Create a session cookie ("the_cookie") and set its value to "the_value"
$.cookie('chocolate_chip_cookie', 'the_value', { // create a cookie with all available options
    expires: 7, // expires in seven days
    path: '/', // accessible from the whole site...
    domain: 'jquery.com',
    secure: true // ...but only on a https connection
});
$.cookie('the_cookie', null); // delete the session cookie
moff