uionut351j
uionut351j

Reputation: 37

How do I get/modify an element in NodeJS

I am new to NodeJS and have used Javascript and PHP for awhile. Is it possible to get an element or edit an element with NodeJS on the server side? Or is this not possible?

HTML

<div id="myDiv">

</div>

<input type="text" id="myInput" value="Hi" />

JavaScript

document.getElementById('myDiv').innerHTML = '<span>Hello World</span>';
console.log(document.getElementById('myInput').value);

Upvotes: 1

Views: 946

Answers (1)

&#214;m&#252;rcan Cengiz
&#214;m&#252;rcan Cengiz

Reputation: 2159

Node.js is an open-source, cross-platform JavaScript run-time environment for executing JavaScript code server-side.

As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications.

It enables JavaScript to be used for server side scripting, and runs scripts server side to produce dynamic web page content before the page is sent to the user's browser.

The purpose is to produce dynamic web page content before the page is sent to user's browser. So you can't modify the DOM from node.

Upvotes: 1

Related Questions