21.) What does the DOMContentLoaded event signify?
A) The DOM is fully constructed.
B) The DOM is partially constructed.
C) The document and CSS are loaded but not images.
D) The document and all resources (images, CSS, etc.) are loaded.
22.) Which of the following is NOT a valid DOM event?
A) click
B) change
C) mouseover
D) hover
23.) How do you detect which key was pressed during a keydown event?
A) event.key
B) event.which
C) event.code
D) All of the above
24.) What happens if you call stopPropagation() inside a capturing phase listener?
A) The event continues in the bubbling phase.
B) The event propagation stops completely.
C) Only the target element receives the event.
D) The event is ignored entirely.
25.) What is the purpose of the focus event in JavaScript?
A) It triggers when an element gains focus.
B) It triggers when an element loses focus.
C) It triggers when a mouse hovers over an element.
D) It triggers when a user types inside an element.
26.) Which of the following methods removes all child nodes of a DOM element?
A) element.removeChildren()
B) element.innerHTML = “”
C) element.clear()
D) element.deleteChildren()
27.) How can you detect if an element has focus?
A) document.hasFocus()
B) element.isFocused()
C) document.activeElement === element
D) element.focused
28.) What will the following code output?
const btn = document.querySelector("#myButton");
btn.addEventListener("click", () => {
btn.disabled = true;
console.log("Button clicked!");
});
btn.click();
A) “Button clicked!” and the button becomes disabled.
B) “Button clicked!” and the button remains enabled.
C) Throws an error.
D) Nothing happens.
29.) What will the following code output?
document.body.addEventListener("click", function(event) {
console.log(event.currentTarget === document.body);
});
A) true
B) false
C) undefined
D) Throws an error
30.) What will the following code output?
let div = document.createElement("div");
console.log(div.parentNode);
A) undefined
B) null
C) document.body
D) Throws an error.
Related