Multi-stylesheet with jQuery cookies (pop-up issue)

$(function() {
    $('#yes a').click(function() {
        $.cookie('AutoPlayTrue', '1', {
            expires: 999
        });
        $('.disableAutoPlay').hide('slow');
        $.cookie('ccss_remembered_style', null);
        $.cookie('AutoPlayFalse', null);
    });
    $('#ccss-no a').click(function() {
        $.cookie('AutoPlayFalse', '1', {
            expires: 999
        });
        $('.disableAutoPlay').hide('slow');
        $.cookie('AutoPlayTrue', null);
    });
    if ($.cookie('AutoPlayFalse') === null) {
        $('.disableAutoPlay').show();
    }
    else {
        $('.disableAutoPlay').hide();
    }

    if ($.cookie('AutoPlayTrue') === null) {
        $('.disableAutoPlay').show();
    }
    else {
        $('.disableAutoPlay').hide();
    }
});

I have a popup with HTML:

<li class="widget ccss" id="ccss-widget-3"><h2 class="widgettitle">Should HipHop97.com Automatically Start Playing Music?</h2>
    <ul id="ccss-list">

        <li id="ccss-no"><a href="http://hiphop97.com/wp-content/themes/hiphop/noAutoPlayCSS.css">No</a></li><li id="yes"><a href="#">Yes</a></li>
    </ul>

</li>

I need, when the "yes" button is selected, just act as a "close", and with the "no show" cookies and the "no" button, I have already developed a stylesheet and the material code that I need. this is to not display the window again with cookies. (The item is in the subject, just labeled as display:none;it is at the top of the main container.)

I tried this, this is a good concept, I think it just doesn't work:

<script type="text/javascript">
jQuery(document).ready(function($) {
    if ($.cookie('AutoPlayFalse')) {
        $('.displayAutoPlay').css('display','none !important');
    }
    if ($.cookie('AutoPlayTrue')) {
        $('.displayAutoPlay').css('display','none !important');
    }
});
</script>
+3
source share
1 answer
if(!$.cookie('autoplay')){
   //display box
}else{
   $.cookie('autoplay',1);
}

I don’t understand why you complicate it too much :)

0
source

All Articles