...

View Full Version : jQuery Need help with Cookies! (Jquery)



UNEXE
09-09-2010, 08:28 PM
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.


<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!

Fumigator
09-10-2010, 03:41 AM
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

UNEXE
09-10-2010, 08:38 AM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum