Questions About DOM

The following questions are not mandatory.

  1. What is the DOM?**

    1. What does DOM stand for, and what is its purpose in web development?
    2. Explain the structure of the DOM.
    3. How does JavaScript interact with the DOM?
    4. What is the difference between the DOM and the HTML source code?
    5. What is a DOM node?
  2. DOM Node Types**

    1. How many types of DOM nodes are there, and what are they?
    2. What is the difference between an Element node and an Attribute node?
    3. What is a Text node?
    4. What is the significance of the nodeType property?
    5. Describe the differences between childNodes, firstChild, and lastChild.
  3. Selecting Elements with the DOM**

    1. How do you select a DOM element by its ID?
    2. What is the difference between getElementsByClassName() and querySelectorAll()?
    3. How do you select the first <p> element in the document using a query selector?
    4. What is returned by document.getElementsByTagName('p')?
    5. Can you select elements using CSS pseudo-classes with querySelectorAll()? Give an example.
  4. Updating/Modifying DOM Elements**

    1. How can you change the text content of an HTML element using JavaScript?
    2. How would you change the href attribute of a <a> tag?
    3. How can you add and remove classes from a DOM element?
    4. How do you change the CSS styles of an HTML element using JavaScript?
    5. How would you remove a specific HTML element from the page?
  5. Creating Elements**

    1. How can you create a new <div> element and add it to the DOM?
    2. How would you add text content to a newly created element?
    3. How would you set the class attribute of a new element?
    4. How do you insert a new element as the first child of an existing element?
    5. How would you create a new <p> element, add text content to it, and then append it to an existing <div> element?
  6. Deleting Elements in the DOM**

    1. How can you delete a specific DOM element?
    2. How do you remove a child element from a specific parent element?
    3. How would you remove all child elements of a given parent element?
    4. What potential issues could arise from not properly managing references when removing elements?
    5. Can you still interact with a DOM element after it has been removed from the DOM? Why or why not?