Search code examples
jquerycheckboxradio-buttonlocal-storage

Need jQuery localstorage to retain checkbox


I know I might not be asking for this, so, sorry.

Any way, I need a jQuery function to retain checkboxes and radio button on page reload/refresh. I have one that works using cookies, but my requirements are quite high(hundreds of checkboxes and radio buttons)

I need a link to some demo or example that uses localstorage (function should be based solely on input IDs.

Thanks in advance.

P.S. I'm not a front end developer...


Solution

  • You don't need a "jquery function", juste use Window.localStorage or Window.sessionStorage directly. It's very simple to use, but note that it only supports strings, not any other types.

    Some tutorial here.