{"id":42638,"date":"2019-01-04T17:18:37","date_gmt":"2019-01-04T09:18:37","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=42638"},"modified":"2018-12-20T18:19:53","modified_gmt":"2018-12-20T10:19:53","slug":"understanding-document-object-model","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/","title":{"rendered":"Understanding Document Object Model (DOM) in Details"},"content":{"rendered":"<p>We have all heard of the <strong>DOM<\/strong>, or <strong>Document Object Model<\/strong>, that gets mentioned from time to time, related to JavaScript. DOM is a pretty important concept in web development. Without it, we wouldn\u2019t be able to <strong>dynamically modify HTML pages<\/strong> in the browser.<\/p>\n<p>Learning and understanding the DOM results in better ways of <strong>accessing, changing, and monitoring<\/strong> different elements of an HTML page. The Document Object Model may also help us <strong>reduce unnecessary increases in script execution time<\/strong>.<\/p>\n<p class=\"note\"><strong>Read Also:<\/strong> <a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/dom-manipulation-javascript-methods\/\">15 JavaScript Methods For DOM Manipulation for Web Developers<\/a><\/p>\n<h2>Data structure trees<\/h2>\n<p>Before talking about what the DOM is, how it comes into existence, how it exists, and what happens inside of it, I want you to know about trees. Not the coniferous & deciduous kind but about the <strong>data structure tree<\/strong>.<\/p>\n<p>It\u2019s a lot easier to comprehend the concept of data structures if we simplify its definition. I would say, a data structure is about <strong>arranging your data<\/strong>. Yes, just plain old arrangement, as you would arrange the furniture in your house or books in a bookshelf or all the different food groups you\u2019re having for a meal on your plate in order to <strong>make it meaningful to you<\/strong>.<\/p>\n<p>Of course, that\u2019s not all there is to a data structure, but that\u2019s pretty much where it all starts. This <strong>\u201carrangement\u201d<\/strong> is at the heart of it all. It\u2019s pretty important in the DOM as well. But we\u2019re not talking about DOM yet, so let me steer you towards a <strong>data structure that you might be familiar with: arrays<\/strong>.<\/p>\n<h3>Arrays & trees<\/h3>\n<p>Arrays have <strong>indices<\/strong> and <strong>length<\/strong>, they can be <strong>multi-dimensional<\/strong>, and have many more characteristics. As much as important it is to know these things about arrays, let\u2019s not bother ourselves with that right now. To us, an array is pretty simple. It\u2019s when you <strong>arrange different things in a line<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/array-1.jpg\" alt=\"Illustration of a simple array\" width=\"800\" height=\"378\"><\/figure>\n<p>Similarly, when thinking of trees, let\u2019s say, it\u2019s about <strong>putting things below one another<\/strong>, starting with only one thing at the top.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/tree-1.jpg\" alt=\"Illustration of a tree structure\" width=\"800\" height=\"378\"><\/figure>\n<p>Now, you might take the single line ducks from before, <strong>turn it upright<\/strong>, and tell me that \u201cnow, every duck is under another duck\u201d. Is it a tree then? It is.<\/p>\n<p>Depending on what your data is or how you\u2019ll be using it, the topmost data in your tree (called the <strong>root<\/strong>) might be something that is <strong>of great importance<\/strong> or something that\u2019s only there to <strong>enclose other elements underneath it<\/strong>.<\/p>\n<p>Either way, the topmost element in a tree data structure does something very important. It provides a place to <strong>start searching for any information we want to extract from the tree<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/tree-3.jpg\" alt=\"Searching in a tree data structure\" width=\"800\" height=\"379\"><\/figure>\n<h2>The meaning of DOM<\/h2>\n<p>DOM stands for <strong>Document Object Model<\/strong>. The Document <strong>points to an HTML (XML) document<\/strong> which is <strong>represented as an Object<\/strong>. (In JavaScript everything can ever only be  represented as an object!)<\/p>\n<p>The Model is <strong>created by the browser<\/strong> that takes an HTML document and creates an object that represents it. We can access this object with JavaScript. And since we use this object to manipulate the HTML document and build our own applications, <strong>DOM is basically an <abbr title=\"Application Programming Interface\">API<\/abbr><\/strong>.<\/p>\n<h2>The DOM tree<\/h2>\n<p>In JavaScript code, the HTML document is <strong>represented as an object<\/strong>. All the data read from that document are <strong>also saved as objects<\/strong>, nested under one another (because like I said before,  in JavaScript everything can ever only be represented as objects).<\/p>\n<p>So, this is basically the physical arrangement of DOM data in code: everything is <strong>arranged as objects<\/strong>. Logically, however, <strong>it\u2019s a tree<\/strong>.<\/p>\n<h2>The DOM Parser<\/h2>\n<p>Every browser software has a program called <strong>DOM Parser<\/strong> that is responsible for <strong>parsing an HTML document into DOM<\/strong>.<\/p>\n<p>Browsers read an HTML page and turn its data into objects that make up the DOM. The information present in these JavaScript DOM\tobjects are logically arranged as a data structure tree known as the DOM tree.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/dom-parser.jpg\" alt=\"DOM Parser\" width=\"800\" height=\"378\"><\/figure>\n<h2>Parsing data from HTML to the DOM tree<\/h2>\n<p>Take a simple HTML file. It has the <strong>root element<\/strong> <code>&lt;html&gt;<\/code>. Its <strong>sub-elements<\/strong> are <code>&lt;head&gt;<\/code> and <code>&lt;body&gt;<\/code>, each has many child elements of their own.<\/p>\n<p>So essentially, the browser <strong>reads the data in the HTML document<\/strong>, something similar to this:<\/p>\n<pre>\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;meta\/&gt;\r\n    &lt;link\/&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;header&gt;\r\n\t\t  &lt;h1&gt;&lt;\/h1&gt;\r\n\t\t\t   &lt;h2&gt;&lt;\/h2&gt;\r\n    &lt;\/header&gt;\r\n    &lt;main&gt;\r\n\t\t  &lt;article&gt;\r\n\t\t\t\t&lt;p&gt;&lt;\/p&gt;\r\n\t\t\t\t&lt;p&gt;&lt;\/p&gt;\r\n\t\t\t\t&lt;p&gt;&lt;\/p&gt;\r\n\t\t  &lt;\/article&gt;\r\n    &lt;\/main&gt;\r\n    &lt;footer&gt;\r\n\t\t  &lt;div&gt;&lt;\/div&gt;\r\n    &lt;\/footer&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>And, <strong>arranges them into a DOM tree<\/strong> like this:<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/dom-tree.jpg\" alt=\"DOM tree\" width=\"800\" height=\"378\"><\/figure>\n<p>The representation of each HTML element (and its belonging content) in the DOM tree is known as a <strong><a target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/Node\/DOM\">Node<\/a><\/strong>. The <strong>root node<\/strong> is the node of <code>&lt;html&gt;<\/code>.<\/p>\n<p>The <strong>DOM interface<\/strong> in JavaScript is called <code>document<\/code> (since it\u2019s the representation of the HTML document). Thus, we access the DOM tree of an HTML document<strong> through the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Document\" target=\"_blank\"><code>document<\/code><\/a> interface<\/strong> in JavaScript.<\/p>\n<p>We can\u2019t only access, but also <strong>manipulate the HTML document<\/strong> through the DOM. We can add elements to a web page, remove & update them. Each time we change or update any nodes in the DOM tree, it <strong>reflects on the web page<\/strong>.<\/p>\n<h2>How nodes are designed<\/h2>\n<p>I have mentioned before that every piece of data from an HTML document is <strong>saved as an object in JavaScript<\/strong>. So, how the data saved as an object can be logically arranged as a tree?<\/p>\n<p>The nodes of a DOM tree have certain characteristics or properties. Almost every node in a tree <strong>has a parent node<\/strong> (the node right above it), <strong>child nodes<\/strong> (the nodes below it) and <strong>siblings<\/strong> (other nodes belonging to the same parent). Having this <em>family<\/em> above, below, and around a node is what qualifies it as a <strong>part of a tree<\/strong>.<\/p>\n<p>This family information of every node is <strong>saved as properties in the object representing that node<\/strong>. For example, <a target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ParentNode\/children\"><code>children<\/code><\/a> is a property of a node that carries a list of the child elements of that node, thus logically arranging its child elements under the node.<\/p>\n<h2>Avoid overdoing DOM manipulation<\/h2>\n<p>As much as we may find updating the DOM useful (in order to modify a web page), there is such a thing as <strong>overdoing it<\/strong>.<\/p>\n<p>Say, you want to update the color of a <code>&lt;div&gt;<\/code> on a web page using JavaScript. What you need to do is <strong>accessing its corresponding DOM node object<\/strong> and update the color property. This shouldn\u2019t affect the rest of the tree (the other nodes in the tree).<\/p>\n<p>But, what if you want to <strong>remove a node from a tree<\/strong> or <strong>add one to it<\/strong>? The whole tree <strong>might have to be rearranged<\/strong>, with the node removed or added to the tree. This is a costly job. It takes time and browser resource to get this job done.<\/p>\n<p>For example, let\u2019s say, you want to <strong>add five extra rows to a table<\/strong>. For every row, when its new nodes are created and added to the DOM, the <strong>tree is updated each time<\/strong>, adding up to five updates in total.<\/p>\n<p>We can avoid this by using the <a target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/DocumentFragment\"><code>DocumentFragment<\/code><\/a> interface. Think of it as a box that could <strong>hold all the five rows<\/strong> and be added to the tree. This way the five rows are <strong>added as one single piece of data<\/strong> and not one by one, leading to only one update in the tree.<\/p>\n<p>This doesn\u2019t only happen when we remove or add elements, but <strong>resizing an element<\/strong> can also affect other nodes, as the resized element might need other elements around it to <strong>adjust their size<\/strong>. So, the corresponding nodes of all the other elements will need to be updated and the HTML elements will be rendered again according to the new rules.<\/p>\n<p>Likewise, when the layout of a web page as a whole is affected, <strong>a part or the whole of the web page might be re-rendered<\/strong>. This is process is known as <strong><a target=\"_blank\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/Reflow\">Reflow<\/a><\/strong>. In order to <strong>avoid excessive reflow<\/strong> make sure you\u2019re not changing the DOM too much. Changes to the DOM aren\u2019t the only thing that can cause Reflow on a web page. Depending on the browser, other factors can contribute to it, too.<\/p>\n<h2>Wrapping up<\/h2>\n<p>Wrapping things up, the DOM is <strong>visualized as a tree<\/strong> made up of all the elements found in an HTML document. Physically (as physical as anything digital can get), it\u2019s a <strong>set of nested JavaScript objects<\/strong> of which properties and methods hold the information that makes it possible to <strong>logically arrange them into a tree<\/strong>.<\/p>\n<p class=\"note\"><strong>Read Also:<\/strong> <a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/css-object-model-cssom\/\">The Beginners Guide to CSS Object Model (CSSOM)<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>We have all heard of the DOM, or Document Object Model, that gets mentioned from time to time, related to JavaScript. DOM is a pretty important concept in web development. Without it, we wouldn\u2019t be able to dynamically modify HTML pages in the browser. Learning and understanding the DOM results in better ways of accessing,&hellip;<\/p>\n","protected":false},"author":145,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[3554,4117,511],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Understanding Document Object Model (DOM) in Details - Hongkiat<\/title>\n<meta name=\"description\" content=\"We have all heard of the DOM, or Document Object Model, that gets mentioned from time to time, related to JavaScript. DOM is a pretty important concept in\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding Document Object Model (DOM) in Details\" \/>\n<meta property=\"og:description\" content=\"We have all heard of the DOM, or Document Object Model, that gets mentioned from time to time, related to JavaScript. DOM is a pretty important concept in\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-04T09:18:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/array-1.jpg\" \/>\n<meta name=\"author\" content=\"Preethi Ranjit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Preethi Ranjit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/\"},\"author\":{\"name\":\"Preethi Ranjit\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\"},\"headline\":\"Understanding Document Object Model (DOM) in Details\",\"datePublished\":\"2019-01-04T09:18:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/\"},\"wordCount\":1389,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/understanding-document-object-model\\\/array-1.jpg\",\"keywords\":[\"DOM\",\"Javascripts\",\"Web Developers\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/\",\"name\":\"Understanding Document Object Model (DOM) in Details - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/understanding-document-object-model\\\/array-1.jpg\",\"datePublished\":\"2019-01-04T09:18:37+00:00\",\"description\":\"We have all heard of the DOM, or Document Object Model, that gets mentioned from time to time, related to JavaScript. DOM is a pretty important concept in\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/understanding-document-object-model\\\/array-1.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/understanding-document-object-model\\\/array-1.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/understanding-document-object-model\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Understanding Document Object Model (DOM) in Details\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e981676afae36d1ff5feb75094950ab3\",\"name\":\"Preethi Ranjit\",\"description\":\"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/preethi\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Understanding Document Object Model (DOM) in Details - Hongkiat","description":"We have all heard of the DOM, or Document Object Model, that gets mentioned from time to time, related to JavaScript. DOM is a pretty important concept in","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/","og_locale":"en_US","og_type":"article","og_title":"Understanding Document Object Model (DOM) in Details","og_description":"We have all heard of the DOM, or Document Object Model, that gets mentioned from time to time, related to JavaScript. DOM is a pretty important concept in","og_url":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2019-01-04T09:18:37+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/array-1.jpg","type":"","width":"","height":""}],"author":"Preethi Ranjit","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Preethi Ranjit","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/"},"author":{"name":"Preethi Ranjit","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3"},"headline":"Understanding Document Object Model (DOM) in Details","datePublished":"2019-01-04T09:18:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/"},"wordCount":1389,"commentCount":1,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/array-1.jpg","keywords":["DOM","Javascripts","Web Developers"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/","url":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/","name":"Understanding Document Object Model (DOM) in Details - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/array-1.jpg","datePublished":"2019-01-04T09:18:37+00:00","description":"We have all heard of the DOM, or Document Object Model, that gets mentioned from time to time, related to JavaScript. DOM is a pretty important concept in","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/array-1.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/understanding-document-object-model\/array-1.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/understanding-document-object-model\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Understanding Document Object Model (DOM) in Details"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e981676afae36d1ff5feb75094950ab3","name":"Preethi Ranjit","description":"A .NET developer with a JavaScript background, Preethi is expert in front-end coding, JavaScript, HTML, and CSS.","url":"https:\/\/www.hongkiat.com\/blog\/author\/preethi\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-b5I","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/42638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/145"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=42638"}],"version-history":[{"count":1,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/42638\/revisions"}],"predecessor-version":[{"id":42639,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/42638\/revisions\/42639"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=42638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=42638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=42638"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=42638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}