101.school
CoursesAbout
Search...⌘K
Generate a course with AI...

    JavaScript 101

    Receive aemail containing the next unit.
    • Introduction to JavaScript
      • 1.1What is JavaScript?
      • 1.2Setting up your environment
      • 1.3Basic syntax and variables
    • Data Types and Variables
      • 2.1Understanding data types
      • 2.2Variables and constants
      • 2.3Operators
    • Control Structures
      • 3.1Conditional statements
      • 3.2Loops
      • 3.3Error handling
    • Functions
      • 4.1Defining functions
      • 4.2Function expressions
      • 4.3Arrow functions
    • Objects and Arrays
      • 5.1Understanding objects
      • 5.2Understanding arrays
      • 5.3Array methods
    • Document Object Model (DOM)
      • 6.1What is the DOM?
      • 6.2Selecting and manipulating elements
      • 6.3Event handling
    • Asynchronous JavaScript
      • 7.1Callbacks
      • 7.2Promises
      • 7.3Async/Await
    • API Interaction
      • 8.1What is an API?
      • 8.2Fetch API
      • 8.3Working with JSON
    • Debugging
      • 9.1Console methods
      • 9.2Debugging tools
      • 9.3Common JavaScript errors
    • JavaScript Libraries
      • 10.1Introduction to libraries
      • 10.2Using jQuery
      • 10.3Using lodash
    • JavaScript Frameworks
      • 11.1Introduction to frameworks
      • 11.2Using React
      • 11.3Using Vue.js
    • Testing and Deployment
      • 12.1Writing tests with Jest
      • 12.2Deployment with Netlify
      • 12.3Continuous integration
    • Final Project
      • 13.1Project proposal
      • 13.2Project development
      • 13.3Project presentation

    Document Object Model (DOM)

    Understanding the Document Object Model (DOM)

    convention for representing and interacting with objects in HTML, XHTML and XML documents

    Convention for representing and interacting with objects in HTML, XHTML and XML documents.

    The Document Object Model, commonly known as the DOM, is a crucial concept to grasp for anyone looking to use JavaScript in web development. It serves as a bridge between your HTML documents and JavaScript, allowing you to manipulate your web pages to create dynamic content.

    What is the DOM?

    The DOM is a programming interface for HTML and XML documents. It represents the structure of a document and allows programs and scripts to manipulate the document's structure, style, and content. The DOM represents a document as a tree of objects; these objects can be manipulated using a scripting language like JavaScript.

    Relationship Between HTML, CSS, and JavaScript in the DOM

    HTML, CSS, and JavaScript are the three core technologies used in creating web content. HTML provides the structure of a page, CSS styles the content, and JavaScript makes it interactive.

    In the DOM, HTML elements are represented as objects, CSS styles can be manipulated through these objects, and JavaScript is used to interact with these objects. This means that JavaScript, through the DOM, can change the structure of the HTML and the appearance of CSS in a webpage.

    Exploring the DOM Tree and Node Relationships

    The DOM represents a document as a tree of objects, known as the DOM tree. Each object, or node, corresponds to a part of the document, such as an HTML tag, an attribute of a tag, or the content within a tag.

    Nodes in the DOM tree have a hierarchical relationship with each other. The topmost node is the Document node, representing the entire document. Elements within the document are child nodes of the Document node. These child nodes can have their own child nodes, creating a tree-like structure.

    The Difference Between the Live DOM and the HTML Source

    When you load a webpage, the browser creates a representation of the page's HTML document in memory — this is the DOM. It's important to note that the DOM is a live, dynamic representation of the page. Any changes made to the DOM using JavaScript are immediately reflected on the page.

    However, these changes do not affect the original HTML source code. If you view the page source in your browser, you'll see the original HTML as it was when the page first loaded. This is a key difference between the live DOM and the HTML source.

    In conclusion, understanding the DOM is fundamental to using JavaScript effectively in web development. It allows you to create dynamic and interactive web content, providing a richer experience for your users.

    Test me
    Practical exercise
    Further reading

    Buenos dias, any questions for me?

    Sign in to chat
    Next up: Selecting and manipulating elements