-2

HTML CODE

Javascript code

Any help would be appreciated! Thanks!

paw
  • 1

1 Answers1

0

Ok, there are a few reasons why your code is not working. The $ I presume is your app's dependence on Jquery and that works fine in the browser, but you have not imported Jquery in node so your app doesn't know what $ is -- in it's mind it is an undefined variable. Moreover, your code is also doing DOM manipulation while also creating an express server. Off the top of my head, I can think of very few to any cases where code like this would be needed, let alone would run properly without some massive compile step. Your best course of action now would be to put all of the Jquery JS into a .js file on your webserver and use it straight from the HTML, not from the actual express.js and node side of things.

User81646
  • 628
  • 4
  • 13
  • His code couldn't even be compiled, because Node.js and Browser JavaScript need different environments to run, and he is trying to run both in one environment. – Take-Some-Bytes Aug 04 '20 at 19:34