script.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. let obj = {
  2. body: {
  3. tagName: 'body',
  4. attrs: {},
  5. paired: true,
  6. children: [
  7. {
  8. tagName: 'div',
  9. attrs: {},
  10. paired: true,
  11. children: [
  12. {
  13. tagName: 'span',
  14. attrs: {},
  15. paired: true,
  16. children: ['Enter data please:']
  17. },
  18. {
  19. tagName: 'br',
  20. paired: false
  21. },
  22. {
  23. tagName: 'input',
  24. attrs: {
  25. type: 'text',
  26. id: 'name'
  27. },
  28. paired: false
  29. },
  30. {
  31. tagName: 'input',
  32. attrs: {
  33. type: 'text',
  34. id: 'surname'
  35. },
  36. paired: false
  37. }
  38. ]
  39. },
  40. {
  41. tagName: 'div',
  42. attrs: {},
  43. paired: true,
  44. children: [
  45. {
  46. tagName: 'button',
  47. attrs: {
  48. id: 'ok'
  49. },
  50. paired: true,
  51. children: ['Ok']
  52. },
  53. {
  54. tagName: 'button',
  55. attrs: {
  56. id: 'cancel'
  57. },
  58. paired: true,
  59. children: ['Cancel']
  60. },
  61. ],
  62. },
  63. ]
  64. }
  65. }
  66. console.log(obj.body.children[0].children[0].children[0])
  67. console.log(obj.body.children[1].children[1].attrs.id)
  68. console.log(obj.body.children[0].children[1].tagName)