I'm having trouble getting jQuery to produce any kind of result with NodeJS. I followed this post 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.
Just to be extra sure I copied the example from jquery.com exactly, but that also fails to work. The console doesn't tell me anything either.
Here's my code
index.html:
<html> <body> <p> <b>Click</b> to change the <span id="tag">html</span> </p> <p> to a <span id="text">text</span> node. </p> <p> This <button name="nada">button</button> does nothing. </p> </body> </html> header.js
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 ); }); I'm very new to Node and also very confused.