DataTransfer: items property

The read-only DataTransfer property items property is a list of the data transfer items in a drag operation. The list includes one item for each item in the operation and if the operation had no items, the list is empty.


A DataTransferItemList object containing DataTransferItem objects representing the items being dragged in a drag operation, one list item for each object being dragged. If the drag operation had no data, the list is empty.


Logging dragged items

This example uses items to log information about dragged items.


  <li id="source1" draggable="true">Drag Item 1 to the Drop Zone</li>
  <li id="source2" draggable="true">Drag Item 2 to the Drop Zone</li>
<div id="target">Drop Zone</div>

<button id="reset">Reset</button>


div {
  margin: 0em;
  padding: 2em;

#target {
  border: 1px solid black;


function dragstartHandler(ev) {
  console.log(`dragstart: = ${}`);
  // Add this element's id to the drag payload so the drop handler will
  // know which element to add to its tree
  ev.dataTransfer.effectAllowed = "move";

function dropHandler(ev) {
  // Get the id of the target and add the moved element to the target's DOM
  const data = ev.dataTransfer.getData("text");;
  // Print each item's "kind" and "type"
  if (ev.dataTransfer.items) {
    for (const item of ev.dataTransfer.items) {
      console.log(`kind = ${item.kind}, type = ${item.type}`);

function dragoverHandler(ev) {
  // Set the dropEffect to move
  ev.dataTransfer.dropEffect = "move";

const source1 = document.querySelector("#source1");
const source2 = document.querySelector("#source2");
const target = document.querySelector("#target");

source1.addEventListener("dragstart", dragstartHandler);
source2.addEventListener("dragstart", dragstartHandler);
target.addEventListener("dragover", dragoverHandler);
target.addEventListener("drop", dropHandler);

const reset = document.querySelector("#reset");
reset.addEventListener("click", () => document.location.reload());



HTML Standard
# dom-datatransfer-items-dev

Browser compatibility

BCD tables only load in the browser

See also