What is the `document` object in JavaScript?
A
A global variable for styling
B
A reference to the HTML document loaded in the browser
Analysis & Theory
The `document` object represents the web page loaded in the browser and is the root of the DOM.
Which of the following accesses the `<body>` of a web page?
Analysis & Theory
`document.body` returns the `<body>` element of the HTML document.
What will `document.title` return?
A
The text inside the `<body>`
B
The URL of the document
C
The `<title>` of the document
D
The name of the HTML file
Analysis & Theory
`document.title` returns the text inside the `<title>` tag of the HTML page.
What does `document.URL` return?
C
The full URL of the document
Analysis & Theory
`document.URL` gives the full URL of the current page.
Which method is used to write directly to the HTML document?
Analysis & Theory
`document.write()` writes content directly into the document, typically during page load.
What does `document.getElementsByClassName()` return?
B
A list of elements with the given class
C
Only the first matching element
D
A string of class names
Analysis & Theory
`getElementsByClassName()` returns a live HTMLCollection of all elements with that class.
Which method returns a NodeList of elements matching a selector?
A
document.querySelector()
B
document.getElementById()
C
document.querySelectorAll()
Analysis & Theory
`document.querySelectorAll()` returns all matching elements as a static NodeList.
What does `document.documentElement` return?
C
The document as a string
Analysis & Theory
`document.documentElement` returns the root `<html>` element.
Which property tells whether the document is fully loaded?
Analysis & Theory
`document.readyState` returns 'loading', 'interactive', or 'complete' depending on load state.
Which method gets an element by name?
A
document.getElementsByName()
Analysis & Theory
`getElementsByName()` returns elements with the specified `name` attribute.