Document Object Model And Event Handling — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Document Object Model And Event Handling — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The central object in a larger API is known as
Correct Answer: Option B — Document Object Model
Detailed Academic Explanation:
The Document object does not stand alone, however. It is the central object in a larger API, known as the Document Object Model, or DOM, for representing and manipulating document content.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The paragraph “p” is a part of
Correct Answer: Option D — Both body and html
Detailed Academic Explanation:
The paragraph tag belongs to both html and body tags.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The node directly above a node is called
Correct Answer: Option C — parent
Detailed Academic Explanation:
The node directly above a node is the parent of that node.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The Text and Comment is part of
Correct Answer: Option A — CharacterData
Detailed Academic Explanation:
The Text and Comment is part of the CharacterData Element.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The nodes that represent HTML elements are the
Correct Answer: Option D — Element nodes
Detailed Academic Explanation:
The nodes that represent HTML elements are Element nodes.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is/are of Text nodes?
Correct Answer: Option C — Both Text and Comment
Detailed Academic Explanation:
Both Text and Comment are basically strings of text, and these nodes are much like the Text nodes that represent the displaying text of a document.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is one of way to query a document for an element or elements?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
he DOM defines a number of ways to select elements; you can query a document for an element or elements: 1. with a specified id attribute; 2. with a specified name attribute; 3. with the specified tag name; 4. with the specified CSS class or classes; or 5. matching the specified CSS selector
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following can be used to select HTML elements based on the value of their name attributes?
Correct Answer: Option B — getElementsByName()
Detailed Academic Explanation:
To select HTML elements based on the value of their name attributes, you can use the getElementsByName() method of the Document object: var radiobuttons = document . getElementsByName (" favorite_color ") ;
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following property refers to the root element of the document?
Correct Answer: Option A — documentElement
Detailed Academic Explanation:
The documentElement property of the Document class refers to the root element of the document. This is always an HTML element.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The return type of getElementsByClassName() is
Correct Answer: Option D — NodeList
Detailed Academic Explanation:
Like getElementsByTagName() , getElementsByClassName() can be invoked on both HTML documents and HTML elements, and it returns a live NodeList containing all matching descendants of the document or element.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which syntax is used to describe elements in CSS?
Correct Answer: Option B — Selectors
Detailed Academic Explanation:
CSS stylesheets have a very powerful syntax, known as selectors, for describing elements or sets of elements within a document.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the following code snippet mean? # log> span
Correct Answer: Option D — Any span child of the element with id as log
Detailed Academic Explanation:
The above code snippet means that any span child of the element with id=”log”.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is the ultiate element selection method?
Correct Answer: Option A — querySelectorAll()
Detailed Academic Explanation:
querySelectorAll() is the ultimate element selection method: it is a very powerful technique by which client-side JavaScript programs can select the document elements that they are going to manipulate.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is the Web application equivalent to querySelectorAll()?
Correct Answer: Option C — $()
Detailed Academic Explanation:
Web applications based on jQuery use a portable, cross-browser equivalent to querySelectorAll() named $() .
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The C in CSS stands for
Correct Answer: Option D — Cascading
Detailed Academic Explanation:
The C in CSS stands for “cascading”. This term indicates that the style rules that apply to any given element in a document can come from a “cascade” of different sources.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The latest version of CSS is
Correct Answer: Option C — CSS3
Detailed Academic Explanation:
The latest version of CSS is CSS3.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is an example of a Shortcut Property?
Correct Answer: Option D — all of the mentioned
Detailed Academic Explanation:
All of the above mentioned properties are shortcut properties. For example, the font-family, font-size, font-style, and font-weight properties can all be set at once using a single font property with a compound value: font : bold italic 24 pt helvetica;
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is the default positioning elements with CSS?
Correct Answer: Option B — static
Detailed Academic Explanation:
static is the default value and specifies that the element is positioned according to the normal flow of document content (for most Western languages, this is left to right and top to bottom).
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which property lays the element according to the normal flow?
Correct Answer: Option A — relative
Detailed Academic Explanation:
When the position property is set to relative, an element is laid out according to the normal flow, and its position is then adjusted relative to its position in the normal flow.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following property allows you to specify an element’s position with respect to the browser window?
Correct Answer: Option B — fixed
Detailed Academic Explanation:
The fixed value allows you to specify an element’s position with respect to the browser window. Elements with fixed positioning are always visible and do not scroll with the rest of the document. Like absolutely positioned elements, fixed-position elements are independent of all others and are not part of the document flow.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The type that specifies what kind of event occured is
Correct Answer: Option A — event type
Detailed Academic Explanation:
The event type is a string that specifies what kind of event occurred) The type “mousemove”, for example, means that the user moved the mouse.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the object on which the event occured or with which the event is associated?
Correct Answer: Option B — event target
Detailed Academic Explanation:
The event target is the object on which the event occurred or with which the event is associated. When we speak of an event, we must specify both the type and the target.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In general, event handler is nothing but
Correct Answer: Option A — function
Detailed Academic Explanation:
An event handler is in general, a function that handles or responds to an event.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When will the browser invoke the handler?
Correct Answer: Option C — Specified event occurs
Detailed Academic Explanation:
When an event of the specified type occurs on the specified target, the browser invokes the handler.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which property specifies the property of the event?
Correct Answer: Option A — Type
Detailed Academic Explanation:
All event objects have a type property that specifies the event type.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The process by which the browser decides which objects to trigger event handlers on is
Correct Answer: Option D — Event propogation
Detailed Academic Explanation:
Event propagation is the process by which the browser decides which objects to trigger event handlers on.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which form of event propogation handles the registered container elements?
Correct Answer: Option C — Event Capturing
Detailed Academic Explanation:
Another form of event propogation, known as event capturing, handlers specially registered on container elements have the opportunity to intercept ( or “capture” ) events before they are delivered to their actual target.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The events that are directly tied to a specific input device are
Correct Answer: Option B — Device-dependent input events
Detailed Academic Explanation:
These are events that are directly tied to a specific input device, such as the mouse or keyboard) They include legacy event types such as “mousedown”, “mousemove”, “mouseup”, “keydown”, “keypress”, and “keyup” and also new touch specific events like “touchmove” and “gesturechange”.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The high-level events among the following events are
Correct Answer: Option A — User interface events
Detailed Academic Explanation:
UI events are higher-level events, often on HTML form elements that define a user interface for a web application. They include the focus event (when a text input field gains keyboard focus), the change event when the user changes the value displayed by a form element, and the submit event when the user clicks a Submit button in a form.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The events that are not directly tied to a specific input device are
Correct Answer: Option B — Device-independent events
Detailed Academic Explanation:
These are input events that are not directly tied to a specific input device. The click event, for example, indicates that a link or button (or other document element) has been activated) This is often done via a mouse click, but it could also be done by keyboard or (on touch-sensitive devices) by gesture.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The events that are not triggered directly by user activity are called
Correct Answer: Option D — State change events
Detailed Academic Explanation:
Some events are not triggered directly by user activity, but by network or browser activity, and indicate some kind of lifecycle or state-related change. The load event, fired on the Window object when the document is fully loaded, is probably the most commonly used of these events.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The video and the audio belong to the
Correct Answer: Option B — API-Specific events
Detailed Academic Explanation:
The HTML5 video and audio elements define a long list of associated event types such as “waiting”, “playing”, “seeking”, “volumechange”, and so on. These events are usually only of interest to web apps that want to define custom controls for video or audio playback.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The client-side JavaScript’s asynchronous programming model contains
Correct Answer: Option A — Timers and error handlers
Detailed Academic Explanation:
Timers and error handlers are part of client-side JavaScript’s asynchronous programming model and are similar to events.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which are the events that have default actions that can be canceled by event handlers?
Correct Answer: Option C — Submit and reset events
Detailed Academic Explanation:
The submit and reset events have default actions that can be canceled by event handlers, and some click events do, too. The focus and blur events do not bubble, but all the other form events do.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The events that represents occurrences related to the browser window are
Correct Answer: Option A — Window
Detailed Academic Explanation:
Window events represent occurrences related to the browser window itself, rather than any specific document content displayed inside the window.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which event is fired when a document and all of its external resources are fully loaded and displayed to the user?
Correct Answer: Option B — Load
Detailed Academic Explanation:
The load event is the most important of these events: it is fired when a document and all of its external resources (such as images) are fully loaded and displayed to the user.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the alternative to the load event?
Correct Answer: Option C — readystatechange
Detailed Academic Explanation:
DOMContentLoaded and readystatechange are alternatives to the load event: they are triggered sooner, when the document and its elements are ready to manipulate, but before external resources are fully loaded.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the opposite to the load event in JavaScript?
Correct Answer: Option D — unload
Detailed Academic Explanation:
The unload event is the opposite of load: it is triggered when the user is navigating away from a document. An unload event handler might be used to save the user’s state, but it cannot be used to cancel navigation.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the property that is triggered in response to JavaScript errors?
Correct Answer: Option C — onerror
Detailed Academic Explanation:
The onerror property of the Window object is something like an event handler, and it is triggered in response to JavaScript errors. It isn’t a true event handler, however, because it is invoked with different arguments.
💡Key Conceptual Anchor:Document Object Model And Event Handling
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which event can be fired on any scrollable document element?
Correct Answer: Option B — Scroll
Detailed Academic Explanation:
Scroll events can also be fired on any scrollable document element, such as those with the CSS overflow property set.
💡Key Conceptual Anchor:Document Object Model And Event Handling
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.