javascript - Keep toogle value on page refresh -


I want to value toogle on page refresh. I try to do this with cookies but it does not work, I can not keep them right and can not figure out how.

Javascript:

  $ ("div # unu"). Click (function () {$ ("div # autori") SlideToggle (); document.cookie = "autori";}); If (document.cookie == 'autori') {$ ('div # unu') Click (); }  

HTML

  & lt; Div id = "unu" & gt; Auto & lt; / Div & gt; & Lt; Div id = "autori" hidden & gt; & Lt; Ul & gt; & Lt; Li & gt; Mark Twain & lt; / Li & gt; & Lt; Li & gt; Mark Twain & lt; / Li & gt; & Lt; Li & gt; Mark Twain & lt; / Li & gt; & Lt; Li & gt; Mark Twain & lt; / Li & gt; & Lt; Li & gt; Mark Twain & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt;  

You must add callback to the sloglag function and if there If this code is not using either set to set local level to either real or false:

  if ($ ("div # autori") .is (": visible ")) {LocalStorage.setItem ('Toggle'," True "); } And {localStorage.setItem ('toggle', "wrong"); }  

Then check for the page when it first loads. Here's a working jsFiddle:


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -