What are the DataTransfer object attributes?


The DataTransfer object holds data about the drag and drop operation. This data can be retrieved and set in terms of various attributes associated with the DataTransfer object.

The following are the attributes:

Sr.No.
DataTransfer attributes and their description
1
dataTransfer.dropEffect [ = value ]

  1. Returns the kind of operation that is currently selected.
  2. This attribute can be set, to change the selected operation.
  3. The possible values are none, copy, link, and move.
2
dataTransfer.effectAllowed [ = value ]

  1. Returns the kinds of operations that are to be allowed.
  2. This attribute can be set, to change the allowed operations.
  3. The possible values are none, copy, copyLink, copyMove, link, linkMove, move, all and uninitialized.
3
dataTransfer.types

Returns a DOMStringList listing the formats that were set in the dragstart event. In addition, if any files are being dragged, then one of the types will be the string "Files".
4
dataTransfer.clearData( [ format ] )

Removes the data of the specified formats. Removes all data if the argument is omitted.
5
dataTransfer.setData(format, data)

Adds the specified data.
6
data = dataTransfer.getData(format)

Returns the specified data. If there is no such data, returns the empty string.
7
dataTransfer.files

Returns a FileList of the files being dragged, if any.
8
dataTransfer.setDragImage(element, x, y)

Uses the given element to update the drag feedback, replacing any previously specified feedback.
9
dataTransfer.addElement(element)

Adds the given element to the list of elements used to render the drag feedback.

Updated on: 29-Jan-2020

261 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements