Ask coding questions

← Back to all posts
add html code in node
floribert10 (2)

hi,
How can i add html code in node.js.
Help me pls

thanks

Answered by JBloves27 (1885) [earned 5 cycles]
View Answer
Comments
hotnewtop
JBloves27 (1885)

Or you can do this:
HTML

<div id="e"></div>

JAVASCRIPT

document.getByElementId("e").innerHTML = "<h1> HI </h1>";

This should work. Hope it helps!

JBloves27 (1885)

You can use the following example:

document.innerHTML = `<h1> Hello World! </h1>`

Then it should display this:

Hello World!

Hope this helps!

IntellectualGuy (823)

@JBloves27 Bruh that's JavaScript not Node.js. Node.js can't access the DOM.

TANMAYBAGADIA (55)

Like do you want to render a html page or just to write the html tags in node.js

TANMAYBAGADIA (55)

@floribert10 Ohk you got the answer now . Plz mark the guy who answered your question if it seems to you was what you were looking for as it would sort the questions

Coder100 (18185)

Lmao that's not node.js