How do I get an HTML Element in node.js express?

Viewed 36

I am building an app in node.js ran into a problem because I couldn't get an HTMLElement

Is it possible to do something like

document.querySelector("#div")

Or

document.getElememtById("div")

But in Node.js express?

My code:

Index.js:

const express = require('express');

// App set up
const app = express();

app.get('/', (req, res) => {
  res.sendFile("Public/index.html", {root: __dirname});
})
app.use(express.static('Public'));

// Listen
app.listen(3000, () => console.log('started'));

/index.html:

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<div id="div"> Hello world! </div>

</body>
</html>
0 Answers
Related