title: Carrying Variable from external link to page and plugging into jQuery script onload
body: <p>I have this jQuery which shows/hides content depending on the list item that's clicked. I also want to be able to show specific content upon landing on this page, dependant on what link the user clicked on another page.</p>
  
  <p>I know that to make this happen, I have to carry the variable over from the other link somehow, and make it act as the variable.</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"&gt;&lt;/script&gt;    
  &lt;script type="text/javascript"&gt; 
  $(document).ready(function() {
  $('#side_nav ul li a').click(function() {
      $('#side_nav ul li.current').removeClass('current');
      $(this).parent().addClass('current');
  
      var filterVal = $(this).attr('class');
  
          $('#content div.section').each(function() {
              if($(this).hasClass(filterVal)) {
                  $(this).fadeIn(200);
              } else {
                  $(this).hide();
              }
          });
      return false;
  });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>I've tried adding #desired_content to the end of the url at the link on the separate page and I know that using window.location.hash, I can pull that hash lable in as the variable somehow but I'm lost as to exactly how to accomplish that.</p>
  
  <p>Please help.</p>
  
  <p>EDIT: I added this to the external page:</p>
  
  <pre><code>&lt;li&gt;&lt;a href="./about.html#how_it_works"&gt;HOW IT WORKS&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>and this to the target page, just to TEST whether the class being added</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  $(document).ready(function() {
      var myHash = window.location.hash;
  
      if( myHash == "#how_it_works" ){
          $('#content div.how_it_works').addClass('test');
      }else if( myHash == "#option2" ){
          // fade in option2
      }
  
  
  });     
  &lt;/script&gt;
  </code></pre>
  
  <p>I don't understand why this isn't working...</p>