J.Gold J.Gold - 4 days ago 6
Javascript Question

Making a web page from Javascript only

So I have been given an assignment to rip down an existing HTML page and rebuild a new one just with Javascript. So I have taken down the page leaving me with the following:

<html>
<head></head>
<body>
<div id="masterDiv>
<div>
</div>
</div>
<script src = Javascript.js></script>
</body>
</html>


From here I want to structure a new site with a header, footer, left column, right column and a body in the middle with only Javascript (I have appended the spare div to the master div)

Answer

All you really need to do this is

Here is a simple example of these three:

var div = document.createElement("div");
div.textContent = "Hello World";
document.querySelector("#container").appendChild(div);
<div id="container"></div>

Comments