So in this repl I made a simple express server and made it serve index.html. The html file has a script tag for running script.js and it executes perfectly because a new element is added to the web page. However if I uncomment line 7 or lines 13-18 of script.js, the element is not added. Why does that happen? I am guessing it has something to do with nodejs vs browser javascript, but I still can’t wrap my head around what’s happening.
@Coder100 Wait, so is there any way I convert it to nodejs? Or would I just have to use it the web/dom way? And if that’s the case, why doesn’t the code work with the event listener eventhough thats also in webjs?
Wierd Nodejs Behaviour
Hello Everyone!
So in this repl I made a simple express server and made it serve
index.html
. The html file has a script tag for runningscript.js
and it executes perfectly because a new element is added to the web page. However if I uncomment line 7 or lines 13-18 ofscript.js
, the element is not added. Why does that happen? I am guessing it has something to do with nodejs vs browser javascript, but I still can’t wrap my head around what’s happening.