Question : check that a cookie exists when page loads using javascript

I need check to see if a cookie exists on the client in order to show some html.  I attempted to use the below by I never to the code to execute when I went to the html page.  It seems as though the code never gets executed since I don't see the text in the div and I don't get an alert.

<script type="text/javascript">

$(document).ready(function() {

      if ($.cookie('cookie_name') == 1) {
        $('adminDiv').html('<p>test show text</p>');
    }
    else{
                alert("else");
          }
});
</script>

HTML:
<div id="adminDiv"></div>

Answer : check that a cookie exists when page loads using javascript

can you alert the following

alert($.cookie('cookie_name'));
alert( typeof $.cookie('cookie_name') );


have you downloaded the jquery cookie plugin from here
http://plugins.jquery.com/project/cookie

Here is the doc on how to use them
http://stilbuero.de/jquery/cookie/#
http://code.google.com/p/cookies/wiki/Documentation#With_jQuery

Random Solutions  
 
programming4us programming4us