I am using JQuery as a layout switch which works fine, but when the user refreshes the page none of the layout options are ‘saved’ if you know what I mean. Is there a way to remember which switch option is selected even if user refreshes/changes page?
For example, if the post-area bg is black and text white, the switch will invert those colours, and will stay unless the user switches back.
I used to do this with php, but I want to do this without php, just jq if somehow possible.
You will definitely need to set a cookie for this if you want to do it with jQuery (or store local data using HTML5 but that is not as universally used or browser accepted, nor needed).
This is a pretty basic function to set a cookie, from here:
and this is a pretty basic one to get a cookie, also from here:
So something like this should work:
and then whenever you want to save the color, just set it like:
EDIT After posting this it occurred to me there is probably a built in function with jQuery to set/get cookies or at least a very good plugin. This page has some good references.