1. When are the mouse events generated?
a) When user clicks the mouse over a document
b) When user moves over a document
c) On pressing a key
d) When user clicks or moves the mouse over a document
Explanation: Mouse events are generated when the user moves or clicks the mouse over a document. These events are triggered on the most deeply nested element that the mouse pointer is over, but they bubble up through the document.
2. The properties that specify the position and button state of the mouse are
a) clientX and clientY
b) clientY and clientX
c) altKey and ctrlKey
d) metaKey and shiftKey
Explanation: The clientX and clientY properties specify the position of the mouse in window coordinates. The clientX property returns the horizontal coordinate (according to the client area) of the mouse pointer when a mouse event was triggered. Similarly clientY returns the vertical coordinates.
3. Which of the following keys are set to true when the keyboard modifier keys are held down?
d) all of the mentioned
Explanation: A modifier key is a key that modifies the action of another key when the two are pressed together. The altKey, ctrlKey, metaKey, and shiftKey properties are set to true when the corresponding keyboard modifier keys are held down.
4. How to detect and respond to mouse drags?
a) Registering a mouseover handler
b) Releasing a mousedown handler
c) Registering a mousedown handler
d) Releasing a mouseover handler
Explanation: By registering a mousedown handler that registers a mousemove handler, you can detect and respond to mouse drags. Doing this properly involves being able to capture mouse events so that you continue to receive mousemove events even when the mouse has moved out of the element it started in.
5. When is the mouseover event fired?
a) When mouse is moved over a new element
b) When mouse is clicked
c) When mouse is both moved and clicked
d) When mouse is released
Explanation: When the user moves the mouse so that it goes over a new element, the browser fires a mouseover event on that element. The onmouseover event occurs when the mouse pointer is moved onto an element, or onto one of its children.
6. When is the mouseout event fired?
a) When mouse is no longer over an element
b) When mouse is over an element
c) When mouse is hovered
d) When mouse is clicked
Explanation: When the mouse moves so that it is no longer over an element, the browser fires a mouseout event on that element. The mouseout() method triggers the mouseout event, or attaches a function to run when a mouseout event occurs
7. The focus and blur events are also part of
a) Element events
b) Handler events
c) Window events
d) Scroll events
Explanation: The focus and blur events are also used as Window events: they are triggered on a window when that browser window receives or loses keyboard focus from the operating system.focusin and onblur methods are used for using these events.
8. The element that can also register handlers for load and error events is
Explanation: Individual document elements, such as img elements, can also register handlers for load and error events.onload and onerror methods are used for handling such events.
9. The events that is emulated by the jQuery library are
a) focusarea and focusover
b) focusall and focusnone
c) focusdown and focusup
d) focusin and focusout
Explanation: The jQuery library emulates focusin and focusout events for browsers that do not support them. The focusin and focusout events bubble, the focus and blur events doesn’t. That means that you can use the focusin and focusout on the parent element of a form field.
10. Which event is triggered sooner when the document and its elements are ready to manipulate?
c) Both DOMContentLoaded & readystatechange
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.