Course: JavaScript

Progress (0%)

  1. Foundation

  2. Numbers

  3. Strings

  4. Conditions

  5. Loops

  6. Arrays

  7. Functions

  8. Objects

  9. Exceptions

  10. HTML DOM

  11. CSSOM

  12. Events

  13. Drag and Drop

  14. opt Touch Events

  15. Misc

  16. Project: Analog Clock

JavaScript Drag-and-Drop Basics Quiz

Quiz 29 12 questions

Prerequisites for the quiz

  1. JavaScript Drag and Drop — Basics

Are you ready?

12 questions to solve

Instructions
  1. This quiz goes to full-screen once you press the Start button.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
The <img> element is draggable by default in web browsers. True or false?
We don't have to manually configure <img> elements to become draggable; they are draggable by default. Hence, the given statement is true. To learn more, refer to JavaScript Drag and Drop — Basics.
The <div> element is draggable by default in web browsers. True or false?
The <div> element is not draggable by default; we have to manually configure it to become one. To learn more, refer to JavaScript Drag and Drop — Basics.
The <a> element, without an href, is draggable by default in web browsers. True or false?
Just like <img>, <a> elements (but only those with an href) are also draggable by default. This means that the statement above is false, hence the choice (B). To learn more, refer to JavaScript Drag and Drop — Basics.
Text selections are draggable by default in web browsers. True or false?
Indeed, text selections are also draggable by default in web browsers. To learn more, refer to JavaScript Drag and Drop — Basics.
How to make any given HTML element draggable?
The draggable HTML attribute is used to make an HTML element draggable. Hence, the correct choice is (A). To learn more, refer to JavaScript Drag and Drop — Basics.
A dropzone element is also referred to as which of the following?
A dropzone element is also referred to by the following names: droppable element, droppable, drop region, and drop target. A source node doesn't refer to a dropzone, but rather to a draggable element. To learn more, refer to JavaScript Drag and Drop — Basics.
The following code does NOT work as expected to make the given <div> element draggable. Explain the problem and how to rectify it.
<div draggable>A div</div>
The draggable attribute is not a Boolean attribute, which means that we can't just specify it as it is inside an element; we have to explicitly set it to a value, which can either be "true" or "false" (or even "auto"). Hence, the correct choice is (B). To learn more, refer to JavaScript Drag and Drop — Basics.
The dragstart event fires on a dropzone as soon as an item is dragged into it. True or false? If false, give the correct statement.
The dragstart event fires on a draggable element as soon as the element is begun to be dragged. Hence, the correct choice is (C). The dragstart event doesn't fire on a dropzone, as indicated in choice (B). To learn more, refer to JavaScript Drag and Drop — Basics.
What does calling preventDefault() inside the dragstart handler do?
When we call preventDefault() upon the dragstart event, the drag operation is effectively canceled — we can't then drag the respective element. Hence, the correct choice is (C). To learn more, refer to JavaScript Drag and Drop — Basics.
Setting draggable="true" on an <img> element is redundant. True or false?
Since <img> elements are already draggable by default, it's redundant to set draggable="true" manually on them. Therefore, the statement above is true. To learn more, refer to JavaScript Drag and Drop — Basics.
The dragover event fires just once on a dropzone element as soon as an item is dragged over it. True or false? If false, then give the correct description.
The dragover event fires as soon as a draggable item is brought over a dropzone element. One unique trait of dragover is that it fires repeatedly (even if we don't move the mouse) on the dropzone. This goes with the choice (B). To learn more, refer to JavaScript Drag and Drop — Basics.
Handling the dragover event and cancelling its default action is necessary to be able to get drop dispatched on an element that's not a dropzone by default. True or false?
If we don't handle dragover and cancel its default behavior, the browser tends to not dispatch a subsequent drop event on the underlying dropzone. Hence, the statement above is absolutely true. To learn more, refer to JavaScript Drag and Drop — Basics.