title: Uncaught ReferenceError $ is not defined
body: <p>I'm very new to JavaScript (just started a few hours ago and trying to get a script working).  I went through a few tutorials on W3 and the <em>'hello world'</em> code works when I paste it directly into my HTML but I'm having a problem with a script (I've had problems with other scripts as well but I am not sure what I'm doing wrong).  </p>
  
  <p>I have this <a href="http://jsfiddle.net/BxpSF/" rel="nofollow noreferrer">code</a> that I want to test in my HTML, I copied the HTML in and it looks the same then I made a file in my static folder called <code>edit.js</code> and copied the JavaScript into it (exactly as shown). It didn't work no errors on the page but when I click it nothing happens.  I tried to paste a W3 <em>'hello world'</em> code in and that worked but this script does not.  </p>
  
  <p>I tried to inspect the code in Chrome and that's where I see the above error (under the resources tab). I can open the js file using Chrome which makes me think the js file is accessible and pointing correctly but I'm not sure how to get it working. I'm using Jinja2 as my template engine to render the HTML and in my header I have:</p>
  
  <pre><code>&lt;script language="JavaScript" type="text/javascript" src="static/edit.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>and in my main template (the one that gets rendered on all pages) I have:</p>
  
  <pre><code>&lt;script language="JavaScript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><strong>edit.js:</strong></p>
  
  <p>(even putting it within the script tag directly on the page I want to use it on doesn't work)</p>
  
  <pre><code>$('#editvalue').click(function(e){$('#storedvalue').hide();$('#altervalue').show();});
  $('#savevalue').click(function(e){
     var showNew = $('#changevalue').val();
     $('#altervalue').hide();
     $('#storedvalue').show();
     $('#storedvalue span').text(showNew);
  });​
  </code></pre>
  
  <p><strong>HTML:</strong> </p>
  
  <p>(it's embedded in a larger page)</p>
  
  <pre><code>    &lt;head&gt;
          &lt;script language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;script language="JavaScript" type="text/javascript" src="static/edit.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
  ... my html code..
          &lt;div id="wrapper"&gt;
             &lt;div id="container"&gt;
                &lt;div id="storedvalue"&gt;&lt;span&gt;Hello&lt;/span&gt; [&lt;a href="javascript:void(0);" id="editvalue"&gt;edit&lt;/a&gt;]&lt;/div&gt;
                &lt;div id="altervalue" style="display:none;"&gt;&lt;input type="text" name="changevalue" id="changevalue" value="Hello"&gt; [&lt;a href="javascript:void(0);" id="savevalue"&gt;save&lt;/a&gt;]&lt;/div&gt;
             &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>I have never been able to successfully run a JavaScript that wasn't on W3 yet.  I get the same problem with other scripts even though I see people online saying they work fine for them.  Do I need to do anything extra to make this work?</p>
  
  <p>My two questions are:</p>
  
  <ul>
  <li>What am I doing wrong? </li>
  <li>Because Javascript seems to just not work when there's a problem, is there a way to get errors or information on what's actually wrong?</li>
  </ul>
  
  <p>I read <a href="https://stackoverflow.com/questions/2075337/uncaught-referenceerror-is-not-defined">Uncaught ReferenceError: $ is not defined?</a> and have been trying to figure this out for the last hour and can't see my problem.</p>