Show/hide using jQuery cookies -


so i've created simple tip box fades in on page load, option close box. i'm trying make box hidden if visitor clicks close link. i'm new cookies, i'm doing wrong, have:

    $('#close').click(function(e) {         jquery.cookie('tip', 'hide', cookieopts);         $(this).parent('div.tip').fadeout(1000);         e.preventdefault();     });      jquery.cookie('tip', 'show', cookieopts);      $('.tip').delay(500).fadein(1000);      var shouldshow = jquery.cookie('tip') == 'show';     var cookieopts = {expires: 7, path: '/'};      if( shouldshow ) {          $('.tip').delay(500).fadein(1000);      }     else {                     $('.tip').css('display', 'none');     }    

i revised code:

http://jsbin.com/ujixi4/4/edit

a little bit simpler, achieves want.

var cookieopts = {expires: 7, path: '/'};  //this isnt working reason alert('c: '+$.cookie('tip')); //debug code  if( $.cookie('tip') == 'hide'){   //do nothing }else{   $('.tip').delay(500).fadein(1000);    //$.cookie('tip', 'hide', {expires: 7, path: '/'}); // add if want cookie disappear on reload (even if don't click) }  $('#close').click(function(e) {   $.cookie('tip', 'hide', {expires: 7, path: '/'});   $('.tip').hide();   }); 

here similar awnser using cookies: jquery change font-size based on cookie?

http://jsbin.com/ufetu5/2/edit


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -