仅使用Javascript制作网页

时间:2022-08-17 20:03:30

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页面并使用Javascript重建一个新页面。所以我删除了页面,留下了以下内容:

<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)

从这里我想构建一个新的网站,其中包含页眉,页脚,左列,右列和中间的主体,只有Javascript(我已将备用div添加到主div)

1 个解决方案

#1


2  

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>

#1


2  

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>