A simple example: I want to have some elements on a page (e.g. divs or table rows), and I want the user to click on them to select them. This seems simple enough in jQuery. To save the elements that the user clicks on without server messages, I thought that a cookie would be an easy way to do this.
This is an assumption that the cookie is OK in this case, right? If this is correct, does the jQuery API have some way to read / write cookie information that is better than the default JavaScript API?
Here is the cookie plugin for jquery https://github.com/carhartl/jquery-cookie
-, W3C- (, , HTML5), WebStorage. , - .
localStorage () sessionStorage (). Window.
localStorage
sessionStorage
Window
:
localStorage.setItem('clicked', 'elementID'); // stores some data localStorage.getItem('clicked'); // returns corresponding data
, . , JSON, .
, "", Modernizr. : localStorage ( sessionStorage) cookie.