Asking
Only logged in members can reply and interact with the post.
Join SimilarWorlds for FREE »

I have a question about Node.js 😬😓

With JavaScript you can write: document.getElementByID
— But with Node.js "document" doesn't exist.

So what's the Node.js version of "document.getElementByID"?
This page is a permanent link to the reply below and its nested replies. See all post replies »
basilfawlty89 · 31-35, M
NodeJS doesn't work with the DOM at all, so you wouldn't need to access DOM elements.

Node is more like a hybrid server and backend system, although you can install front-end frameworks like React or Angular.

That said, if you use React for the frontend part of the site, there's better methods than document.getElementByID.
Entheesa · 31-35, F
@basilfawlty89 [quote]That said, if you use React for the frontend part of the site, there's better methods than document.getElementByID[/quote]

Could you some of those better methods so I can google them? Thank you so much for your answer, I'm quite confused about how Node.js works.
basilfawlty89 · 31-35, M
@Entheesa you'll first need to learn a bit of React for this to make sense. Bear in mind React uses JSX, which is a bit of a hybrid between JavaScript and HTML. It seems weird at first, but it works well.

https://reactjs.org/docs/dom-elements.html
Entheesa · 31-35, F
@basilfawlty89 This already helps my understanding a lot, thank you! I'll find some videos to teach me about React. Would it be okay to PM you if I have other questions?
basilfawlty89 · 31-35, M
@Entheesa of course :)