zsydgithub 2 gadi atpakaļ
vecāks
revīzija
e70677007f
2 mainītis faili ar 97 papildinājumiem un 0 dzēšanām
  1. 85 0
      6_Dom/1_基础.html
  2. 12 0
      6_Dom/2_练习.html

+ 85 - 0
6_Dom/1_基础.html

@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Document</title>
+  <style>
+    .xx{
+      background: red;
+    }
+    #divn{
+      width: 200px;
+      height: 200px;
+      background: aquamarine
+    }
+  </style>
+</head>
+<body>
+  <div id="div1">
+    hhhhhhhh
+    <div id="div3">llllllllll</div>
+  </div>
+  <div id="div2">xxxxxxx</div>
+
+  <div class="xx">11111111111111</div>
+  <div class="xx">222222222222222222</div>
+  <div class="xx">333333333333333</div>
+
+  <ul id="ul1">
+    <li>1</li>
+    <li>2</li>
+    <li>3</li>
+  </ul>
+  <ul id="ul2">
+    <li class="xx">4</li>
+    <li>5</li>
+    <li class="xx">6</li>
+    <li>7</li>
+    <li class="xx">8</li>
+    <li>9</li>
+  </ul>
+  <button id="btn">点击</button>
+  <div id="divn">我是正方形</div>
+  <script>
+    var div1 = document.getElementById('div1')
+    var xx = document.getElementsByClassName('xx') // 数组
+
+    var ul1 = document.getElementById('ul1')
+    var uli = ul1.getElementsByTagName('li')
+    
+    var ul2 = document.getElementById('ul2')
+    var xli = ul2.getElementsByClassName('xx')
+
+    var btn = document.getElementById('btn')
+    var divn = document.getElementById('divn')
+
+    console.log(xli)
+    div1.onclick = function(){
+      console.log(xx)
+    }
+
+    for(var i=0;i<xx.length;i++){
+      console.log(xx[i])
+      xx[i].onclick = function(){
+        console.log('我是11')
+      }
+    }
+
+    for(var i=0;i<uli.length;i++){
+      uli[i].onclick = function (){
+        console.log('我是uli')
+      }
+    }
+
+    for(var i=0;i<xli.length;i++){
+      xli[i].style.background = 'yellow'
+    }
+
+    btn.onclick = function(){
+      divn.style.width = '400px'
+    }
+  </script>
+</body>
+</html>

+ 12 - 0
6_Dom/2_练习.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Document</title>
+</head>
+<body>
+  
+</body>
+</html>