zheng 1 روز پیش
والد
کامیت
d6c5f1f6c3
3فایلهای تغییر یافته به همراه59 افزوده شده و 0 حذف شده
  1. 4 0
      html5/1.json
  2. 22 0
      html5/5.属性.html
  3. 33 0
      html5/6.json.html

+ 4 - 0
html5/1.json

@@ -0,0 +1,4 @@
+{
+    "name":"我看见",
+    "nam1":"我看见"
+}

+ 22 - 0
html5/5.属性.html

@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <div id="box" data-aa="你好" data-aa-bb="ab"></div>
+    <script>
+        const box1 = document.getElementById("box");
+        box1.setAttribute('address','哈尔滨');
+        console.log(box.getAttribute("address"));
+        box1.dataset.bb = 'hi';
+        console.log(box1.dataset.aa);
+        console.log(box1.dataset.bb);
+        console.log(box1.dataset.aaBb);
+        box1.cc = '12';
+        console.log(box1.cc);
+    </script>
+</body>
+</html>

+ 33 - 0
html5/6.json.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <!-- json 数据格式
+        键名必须是双引号
+        只能是双引 不能是单引号 
+        不能注释
+        最后一个属性后面不能加逗号
+        json是字符串
+        JSON.stringify(js对象转json对象)
+        JSON.parse(json对象转js对象)
+    -->
+     <script>
+        let obj1 = {
+            name:'你好'
+        }
+        let obj2 = {
+            "name":"家家"
+        }
+        // console.log(JSON.parse(JSON.stringify(obj1)));
+        let obj3 = JSON.stringify(obj1);       
+        console.log(obj3) 
+        obj3 = {"name":"你好"};
+        // console.log(obj1,'obj1');
+        console.log((obj3),'obj3');
+     </script>
+</body>
+</html>