javascript - Hide show content with Cookies -


I want to create a form that sets the cookie on depositing, after which the content on the subsequent pages The existence of the cookie depends on the hidden or showing.

I have used this code on jquery.cookie.js and the form:

  $ (document) .ready (function () {$ (". "). ('Click', function () {$ .cookie ('showcontent', true, {expires: 7});});});  

and the following pages on this code:

css

  .contentA {display: none;}  < / Pre> 

javascript

  if (! $ Cookie ('showcentant')) {$ (".contentA") Show (); $ (".contentB") .hide (); }  

HTML

  & lt; Div class = "contentA" & gt; & Lt; H1 & gt; Content A & lt; / H1> & Lt; / Div & gt; & Lt; Div class = "contentB" & gt; & Lt; H1 & gt; Content B & lt; / H1> & Lt; / Div & gt;  

This does not work right now, so any help would really be appreciated.

If you think this works, but this is a cookie, which is stored in the user's browser , Then it should be like this:

  if ($ .cookie ('showcontent') == 'true')  

and cookie library Be sure to load jquery before adding


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -