fengchuanyu 9 luni în urmă
părinte
comite
0baa5b1c04
2 a modificat fișierele cu 69 adăugiri și 0 ștergeri
  1. 20 0
      DOM&BOM/6_DO事件绑定.html
  2. 49 0
      DOM&BOM/练习1_倒计时.html

+ 20 - 0
DOM&BOM/6_DO事件绑定.html

@@ -0,0 +1,20 @@
+<!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>
+    <h1>hello</h1>
+    <h1>world</h1>
+    <script>
+        var oH1 = document.getElementsByTagName("h1");
+        oH1[0].onclick = function(){
+            // console.log("hello world")
+            // oH1[0].innerText = "你好";
+            this.innerText = "hello world"
+        }
+    </script>
+</body>
+</html>

+ 49 - 0
DOM&BOM/练习1_倒计时.html

@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <style>
+        .box{
+            width: 300px;
+            height: 300px;
+            background-color: #aaa;
+            box-shadow: 0 0 10px rgba(0,0,0,.5);
+            border-radius: 10px;
+            position: fixed;
+            top:50%;
+            left:50%;
+            margin-left: -150px;
+            margin-top: -150px;
+            text-align: center;
+            line-height: 300px;
+            font-size: 40px;
+            font-weight: 500;
+        }
+    </style>
+</head>
+<body>
+    <div class="box">
+        <span>10</span>
+    </div>
+    <script>
+        var oSpan = document.getElementsByTagName("span");
+        var num = 10;
+
+        var setObj = setInterval(function(){
+            if(num == 0){
+                clearInterval(setObj);
+            }
+            oSpan[0].innerText = num--;
+        },1000);
+       
+       
+       
+        // oSpan[0].innerText = "hello world";
+
+        // var arr = [1,2,3,4]
+        // arr[0] = "a"
+    </script>
+</body>
+</html>