title: Global javascript variable inside document.ready
body: <p>Which is the right way of declaring a global javascript variable? The way I'm trying it, doesn't work</p>
  
  <pre><code>$(document).ready(function() {
  
      var intro;
  
      if ($('.intro_check').is(':checked')) {
          intro = true;
          $('.intro').wrap('&lt;div class="disabled"&gt;&lt;/div&gt;');
      };
  
      $('.intro_check').change(function(){
          if(this.checked) {
              intro = false;
              $('.enabled').removeClass('enabled').addClass('disabled');
          } else {
              intro = true;
              if($('.intro').exists()) {
                  $('.disabled').removeClass('disabled').addClass('enabled'); 
              } else {
                  $('.intro').wrap('&lt;div class="disabled"&gt;&lt;/div&gt;');
              }
          }
      });
  });
  
  console.log(intro);
  </code></pre>