The Document Object Model

The Document Object Model

The Document Object Model The Document Object Model (DOM) is a description of how an HTML (or XML) document is represented in a tree-like structure. The tree represents the various types of content in a document - primarily types of content (nodes) representing elements or tags (such as <body> and <p>). This model (the DOM of HTML, XHTML, and XML documents on the Internet) gives the JavaScript/ECMAScript language a mapping structure. HTML documents have a hierarchical structure that is represented in the DOM as a tree structure. Below is another depiction of the DOM (Document Object Model) The Document Object Model is both platform-neutral and language-neutral. The Document Object Model (DOM) is actually an application programming interface (API) for manipulating HTML documents... It represents a document as a tree of nodes. It allows you to effectively add, remove, and modify parts of the document. Consider the following HTML document: HTML DOM Mapping Window Document <html> html <head> head <title>D O M</title> title </head> text D O M <body> body <p>The DOM</p> p </body> text The DOM </html> The DOM Mapping represents parent and child nodes of the HTML document. o Mapping the DOM The concept of "." Dot Syntax is used to combine objects (or element) with names, methods, and properties. For example: below is the Window object with window.status = "Nucamp HTML CSS and JS."; next is an object with a method: window.document.write("Hello Nucamp"); And finally to map an element in the DOM: X = window.document.formName.elementName.value or window.document.form01.textBox01.value = “Nucamp” form01 textBox01 * * * A Common Approach for mapping the DOM * * * x = document.getElementById(‘elementID’).method/property querySelector vs getElementById querySelector is a little slower but easy to use… x = document.querySelector (‘.elementID’).method/property Sometimes you will also see Array Notation x = document.forms[0].elements[0].text //Array Notation .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us