1_html_tree.js 950 B

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