Aha, now I saw your comment that you've already found the plugin...
I think it's explained fairly easily.
When you want to create a cookie (or update it's value) you use $.cookie('the_cookie', 'the_value');
The name of the cookie could i.e. be something with the element's id in it (so give all the elements an id if you havn't already). Something like this
Code:
$(document).ready(function(){
$("a.switch_thumb").toggle(
function(){
$(this).addClass("swap");
$("ul.display").fadeOut(100, function() {
$(this).fadeIn(100).addClass("thumb_view");
});
var name = "menu_cookie_" + $(this).attr("id");
$.cookie(name, "open");
},
function () {
$(this).removeClass("swap");
$("ul.display").fadeOut(100, function() {
$(this).fadeIn(110).removeClass("thumb_view");
});
var name = "menu_cookie_" + $(this).attr("id");
$.cookie(name, "closed");
});
});
This will create session cookies, which means that they will be destroyed when you close the browser. To set cookies with an absolute termination time, use this instead
Code:
$.cookie(name, 'value', { expires: 7 }); // cookie exists for 7 days
And, if you want the cookie the be valid for the entire site (rather than just that one page) use this instead
Code:
$.cookie(name, 'value', { expires: 7, path: '/' });
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
Last edited by lizciz; 10-29-2011 at 03:24 PM..
|