Browse Source

'html tree' task done

miskson 3 years ago
parent
commit
f9e7fa0643
1 changed files with 34 additions and 9 deletions
  1. 34 9
      hw4/script.js

+ 34 - 9
hw4/script.js

@@ -1,19 +1,20 @@
+//html tree
 let obj = {
     body: {
         tagName: 'body',
         attrs: {},
         paired: true,
-        children: [
+        subTags: [
             {
                 tagName: 'div',
                 attrs: {},
                 paired: true,
-                children: [
+                subTags: [
                     {
                         tagName: 'span',
                         attrs: {},
                         paired: true,
-                        children: ['Enter data please:']
+                        text: 'Enter data please:',
                     },
         
                     {
@@ -44,14 +45,14 @@ let obj = {
                 tagName: 'div',
                 attrs: {},
                 paired: true,
-                children: [
+                subTags: [
                     {
                         tagName: 'button',
                         attrs: {
                             id: 'ok'
                         },
                         paired: true,
-                        children: ['Ok']
+                        text: 'Ok'
                         
                     },
                     {
@@ -60,7 +61,7 @@ let obj = {
                             id: 'cancel'
                         },
                         paired: true,
-                        children: ['Cancel']
+                        text: 'Cancel'
                     },
                 ],
             },
@@ -68,8 +69,32 @@ let obj = {
     }
 }
 
-console.log(obj.body.children[0].children[0].children[0])
+console.log(`<button id='cancel'> innerText:`, obj.body.subTags[1].subTags[1].text)
+console.log(`<input type='text' id='surname'> id:`, obj.body.subTags[0].subTags[3].attrs.id)
 
-console.log(obj.body.children[1].children[1].attrs.id)
-console.log(obj.body.children[0].children[1].tagName)
+//declarative fields
+var notebook = {
+    brand: "HP",
+    type:  "440 G4",
+    model: "Y7Z75EA",
+    ram: 4,
+    size: "14",
+    weight: 1.8,
+    resolution: {
+        width: 1920,
+        height: 1080,
+    },
+};
 
+var phone = {
+    brand: "meizu",
+    model: "m2",
+    ram: 2,
+    color: "black",
+};
+
+var person = {
+    name: "Donald",
+    surname: "Trump",
+    married: true,
+}