title: Using Jquery in NodeJS
body: <p>I'm having trouble getting jQuery to produce any kind of result with NodeJS. I followed <a href="https://stackoverflow.com/questions/1801160/can-i-use-jquery-with-node-js">this post</a> to actually get it to work through Node, so now my page displays. However none of the code I write in jQuery actually does anything.</p>
  
  <p>Just to be extra sure I copied the <a href="http://api.jquery.com/html/" rel="nofollow noreferrer">example</a> from jquery.com exactly, but that also fails to work. The console doesn't tell me anything either.</p>
  
  <p>Here's my code </p>
  
  <h1>index.html:</h1>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
   &lt;p&gt;
     &lt;b&gt;Click&lt;/b&gt; to change the &lt;span id="tag"&gt;html&lt;/span&gt;
   &lt;/p&gt;
   &lt;p&gt;
     to a &lt;span id="text"&gt;text&lt;/span&gt; node.
   &lt;/p&gt;
   &lt;p&gt;
     This &lt;button name="nada"&gt;button&lt;/button&gt; does nothing.
   &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <h1>header.js</h1>
  
  <pre><code>var http = require('http');
  var fs = require('fs');
  var jsdom = require("jsdom");
  const { JSDOM } = jsdom;
  const { window } = new JSDOM();
  const { document } = (new JSDOM('')).window;
  global.document = document;
  
  var $ = jQuery = require('jquery')(window);
  
  http.createServer(function (req, res) {
    fs.readFile('/home/leonardo/Desktop/Header/index.html', function(err, data) {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.write(data);
      res.end();
    });
  
  }).listen(8080);
  
  $( "p" ).click(function() {
    var htmlString = $( this ).html();
    $( this ).text( htmlString );
  });
  </code></pre>
  
  <p>I'm very new to Node and also very confused.</p>