hw07_11.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <header>
  2. <h1>Destructure</h1>
  3. </header>
  4. <body>
  5. <script>
  6. html =
  7. {
  8. "tagName": "body",
  9. "children": [
  10. {
  11. "tagname": "div",
  12. "children": [
  13. {
  14. "tagName": "span",
  15. "children": [
  16. "Enter a data please:"
  17. ],
  18. },
  19. {
  20. "tagName": "br"
  21. },
  22. {
  23. "tagName": "input",
  24. "attrs": {
  25. "type": "text",
  26. "id": "name"
  27. }
  28. },
  29. {
  30. "tagName": "input",
  31. "attrs": {
  32. "type": "text",
  33. "id": "surname"
  34. }
  35. }
  36. ]
  37. },
  38. {
  39. "tagName": "div",
  40. "children": [
  41. {
  42. "tagName": "button",
  43. "attrs": {
  44. "id": "ok"
  45. },
  46. "children": [
  47. "OK"
  48. ]
  49. },
  50. {
  51. "tagName": "button",
  52. "attrs": {
  53. "id": "cancel"
  54. },
  55. "children": [
  56. "Cancel"
  57. ]
  58. }
  59. ]
  60. }
  61. ]
  62. };
  63. const { children: [{ children: [{ children: [spanValue] }] }] } = html;
  64. children[1].children[1].children[0];
  65. const { children: [, { children: [, { children: [btnValue] }] }] } = html;
  66. const { children: [{ children: [, , , { attrs: { id } }] }] } = html;
  67. </script>
  68. </body>