Search Results

Search found 1 results on 1 pages for 'dilwin'.

Page 1/1 | 1 

  • Show/hide using jQuery cookies

    - by Dilwin
    So I've created a simple tip box that fades in on page load, with an option to close the box. I'm trying to make the box hidden if the visitor clicks the close link. I'm fairly new to cookies, so I'm probably doing it all wrong, but this is what I 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'); }

    Read the article

1