Selaa lähdekoodia

Did lesson on DOM, querySelector() and querySelectorAll

Signed-off-by: Michael Tang <michael.h.tang@gmail.com>
Michael Tang 5 vuotta sitten
vanhempi
commit
456d944b61
2 muutettua tiedostoa jossa 17 lisäystä ja 1 poistoa
  1. 3 1
      index.html
  2. 14 0
      notes-app.js

+ 3 - 1
index.html

@@ -2,11 +2,13 @@
 
 <html>
     <head>
-
+        
     </head>
     <body>
         <h1>Notes App</h1>
         <h2>Take notes and never forget</h2>
         <p>This applicaiton was created by Michael Tang</p>
+        <p>Some note</p>
+        <script src="notes-app.js"></script>
     </body>
 </html>

+ 14 - 0
notes-app.js

@@ -0,0 +1,14 @@
+// DOM - Document Object Model
+
+// Query and remove
+//  const p = document.querySelector('p')
+//  p.remove()
+
+ // Query all and remove
+ const ps = document.querySelectorAll('p')
+
+ ps.forEach(function(p) {
+     p.textContent = '******'
+    //  console.log(p.textContent)
+    //  p.remove()
+ })