- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Jquery Cookie
Hi all,
I need to set a cookie using jquery (I think jquery is the simplest and I like simple:))
I have this:
$("#close").click(function(){
$("#block").fadeOut(200);
});
$("#open").click(function(){
$("#block").fadeIn(200);
});
The code hides and shows a (div) block of content. I need a cookie so that a visitor is not presented with the default style every time one visits my website.
Thanks
Hi soap,
When I was googling the anwser the links you give me where the first I encountered. This was two days a go and I still don’t understand…
Using the jQuery cookie plugin – you would need to do the following (in order):
To set the cookie, it would look like:
setCookie(name, value);
To see if the user already has the cookie – you would do:
if($.cookie(name))
{
// Cookie already set
// Do something
}
else
{
// Cookie not set - so set it
setCookie(name, value);
}
Hi,
Thank you both but I just used this:
http://www.vagrantradio.com/2009/10/getting-and-setting-cookies-with-jquery.html
I modifed to my own script and it all works fine now. Thanks again anyway.
Good work