Hide element depending on value of if/else statement not working
<p>I have a Rails app that uses the <a href="https://developer.linkedin.com/documents/sign-linkedin" rel="nofollow">LinkedIn Javascript API</a> to authenticate users. What I'd like to do is hide an element depending on whether the user is signed up or not. I've tried a few things:</p>

<ul>
<li>Put the code with the if/else statement at the bottom of the HTML before <code>&lt;/body&gt;</code></li>
<li>Check to see if <code>document.cookie</code> is an empty string instead of a more specific if/else</li>
</ul>

<p>However, neither of these has hidden the element. If I go into my browser's console and paste in my code after the page is finished rendering, the element hides. So I thought this was a JavaScript load issue, but I must be doing something wrong. Can anyone shed some light on this?</p>

<p>Here's the code I've tried, none of which works:</p>

<pre><code>&lt;%= content_for(:script_footer) do %&gt;
  &lt;script type="text/javascript"&gt;

    // if ($('span.IN-widget:contains("inSign in with LinkedIn")').length &gt; 0) {
    //   $('#select').hide();
    // } else {
    //   $('#select').show();
    // }

    if (document.cookie == "") {
      $('#select').hide();
    } else {
      $('#select').show();
    }
  &lt;/script&gt;
&lt;% end %&gt;
</code></pre>

<p>And my application layout:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;rdtrip&lt;/title&gt;
  &lt;%= stylesheet_link_tag    "application", :media =&gt; "all" %&gt;
  &lt;%= yield(:linked_in) %&gt;
  &lt;%= javascript_include_tag "application" %&gt;
  &lt;%= csrf_meta_tags %&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;%= yield %&gt;
&lt;%= yield(:script_footer) %&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
