title: jQuery - Uncaught TypeError: $ is not a function
body: <p>I am so confused...I was working on my site and added some jQuery. Upon testing, I found that the jQuery didn't do anything. I then tried the most simple yet visible code I could think of:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    $("html").click(function() {
      $("html").html("");
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>but that didn't do anything either. So I tried that same code in the js console and got back this error:</p>
  
  <pre><code>Uncaught TypeError: $ is not a function
    at &lt;anonymous&gt;:2:1
    at Object.InjectedScript._evaluateOn (&lt;anonymous&gt;:848:140)
    at Object.InjectedScript._evaluateAndWrap (&lt;anonymous&gt;:891:34)
    at Object.InjectedScript.evaluate (&lt;anonymous&gt;:627:21)
  </code></pre>
  
  <p>and just entering <code>$</code> just gives back "undefined".</p>
  
  <p>I investigated and found that I had accidentally moved my Gemfile, and that maybe the server couldn't access the <code>jquery-rails</code> gem. But after I moved it back and restarted the server, the problem didn't go away.</p>
  
  <p>Then I thought maybe I had some faulty code on my page that was preventing the jQuery from running. I removed all the code so it was a just a blank document, ran it, and tried again, but I got the same errors in the console.</p>
  
  <p>The <code>head</code> of my app includes this:</p>
  
  <pre><code>&lt;head&gt;
    &lt;%= javascript_include_tag 'application', 'data-turbolinks-track' =&gt; true %&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>My <code>app/assets/javascripts/application.js</code> includes the line <code>//= require jquery</code></p>
  
  <p>And <code>bundle install</code> returns "jquery-rails 4.1.1".</p>
  
  <p>I've ran plenty of jQuery before on the same page with no issues. It seems my server suddenly just stopped understanding jQuery. What on earth could be going on?</p>