DOM Manipulation Interview Questions

    Question 1Accessing Element by ID

    Which method is used to get an element by its ID?

    Question 2Accessing Multiple Elements

    Which method returns a live HTMLCollection of elements with a given class name?

    Question 3Modifying Text Content

    How do you change the text inside an element with ID title?

    Question 4Creating Elements

    Which method creates a new HTML element?

    Question 5Appending Elements

    How do you add a newly created element p to the body?

    Question 6Changing Attributes

    How can you change the src attribute of an image with ID pic?

    Question 7Removing Elements

    Which method removes a child node from the DOM?

    Question 8Event Listener

    How do you add a click event listener to a button with ID btn?

    Question 9Query Selector

    Which method selects the first element that matches a CSS selector?

    Question 10querySelectorAll vs getElementsByClassName

    What is the difference between querySelectorAll and getElementsByClassName?