title: document.getElementbyId() returning null
body: <p>In the code at the line marked as //Error in comments. I get Javascript error saying: "Cannot read property style of 'null'". I have no idea what it is not able to find the object. I have thought and tried everything. Please help. Here is the code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      $.getJSON('https://graph.facebook.com/647045111?fields=first_name&amp;&lt;%= Session["Token"] %&gt;',
  
      function (data) {
          $('#userName').html(data.first_name);
      });
  
      document.getElementById('connectedUnregistered').style.display = 'block'; //Error
  
  &lt;/script&gt;
  
      &lt;div id="userName"&gt;&lt;/div&gt;
  
      &lt;div id="disconnected" style="display:block;"&gt;
  
       &lt;div id="heading"&gt;Facebook login&lt;/div&gt; 
  
       &lt;a href="Account/FacebookLogin" id="loginButton"&gt;&lt;div id="fbConnectButton"&gt;&lt;img src="/Content/Images/fbconnect.png"/&gt;&lt;/div&gt;&lt;/a&gt;    
  
      &lt;/div&gt;
  
       &lt;div id="connectedUnregistered" style="display:none"&gt;
  
       &lt;div id="heading"&gt;Register Now&lt;/div&gt; 
  
  
  
      &lt;/div&gt;
  </code></pre>