瀏覽代碼

html test

布丁撞奶茶 7 月之前
父節點
當前提交
4e9cf945ff
共有 2 個文件被更改,包括 53 次插入0 次删除
  1. 23 0
      s202226701012/workspace/add.js
  2. 30 0
      s202226701012/workspace/test.html

+ 23 - 0
s202226701012/workspace/add.js

@@ -0,0 +1,23 @@
+let x = 1;
+let y = 2;
+let z = x + y;
+console.log(x);
+console.log(y);
+console.log(z);
+
+// let fireE1 = document.createElementNS("h1");
+// fireE1.innerHTML = "火元素";
+// fire.style.color = "red";
+// doucument.body.appendChild(fireE1);
+// doucument.body.innerHTML = doucument.body.appendChild(fireE1) + "火元素";
+// 创建一个新的 h1 元素
+var h1 = document.createElement("h1");
+
+// 设置 h1 的内容
+h1.textContent = "火元素";
+
+// 设置 h1 的样式
+h1.style.color = "red";
+
+// 将 h1 元素插入到 body 的末尾
+document.body.appendChild(h1);

+ 30 - 0
s202226701012/workspace/test.html

@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+  <head>
+    <!-- 文档编码 -->
+    <meta charset="UTF-8" />
+
+    <!-- 视口设置,确保页面在移动设备上正确显示 -->
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+
+    <!-- 页面标题 -->
+    <title>test</title>
+  </head>
+
+  <body>
+    <!-- 页面主体内容 -->
+
+    <header>
+      <h1>欢迎来到我的网页</h1>
+    </header>
+    <script src="add.js"></script>
+    <main>
+      <p>页面测试</p>
+      <p>你可以在这里添加更多内容。</p>
+    </main>
+
+    <footer>
+      <p>&copy; 2024 布丁撞奶茶. 保留所有权利。</p>
+    </footer>
+  </body>
+</html>