title: JQuery cannot be used in Watir with PhantomJS after adding the script into the DOM
body: <p>I'm trying to interact with website with no JQuery by using <strong>Watir</strong> and <strong>PhantomJS</strong>.</p>
  
  <pre><code>browser = Watir::Browser.new :phantomjs, :args =&gt; ['--ignore-ssl-errors=yes']
  browser.goto 'http://putlocker.is/'
  
  browser.execute_script(    
    "var the_script = document.createElement('script');
    the_script.setAttribute('src','http://code.jquery.com/jquery-1.11.0.min.js');
    document.body.appendChild(the_script);"
  )
  
  browser.execute_script('$("div").hide();')
  </code></pre>
  
  <p>With <strong>Firefox</strong> instead of <strong>PhantomJS</strong> it works fine - JQuery is loaded on a page and I can manage elements using JQuery. But <strong>PhantomJS</strong> raises this error:</p>
  
  <blockquote>
    <p><strong>{"errorMessage":"Can't find variable: $","request":{"headers":{"Accept":"application/json","Accept-Encoding":"gzip;q=1.0,deflate;q=0.6,identity;q=0.3","Connection":"close","Content-Length":"41","Content-Type":"application/json;
    charset=utf-8","Host":"127.0.0.1:8910","User-Agent":"Ruby"},"httpVersion":"1.1","method":"POST","post":"{\"script\":\"$(\\"div\\").hide();\",\"args\":[]}","url":"/execute","urlParsed":{"anchor":"","query":"","file":"execute","directory":"/","path":"/execute","relative":"/execute","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute","queryKey":{},"chunks":["execute"]},"urlOriginal":"/session/84f7d6d0-7035-11e4-a8b8-85c94f571d8e/execute"}}
    (ReqHand)</strong></p>
  </blockquote>
  
  <p>I guess this issue is somehow related to this question: <a href="https://stackoverflow.com/questions/15302928/cant-find-variable-phantomjs">Can&#39;t find variable - PhantomJS</a>. But how to change <strong>Watir</strong> code so that it works?</p>