What is the Datatransfer property for?

Asked

Viewed 157 times

3

I am learning drag and drop in Javascript and I’m not really understanding what the property is for DataTransfer, for example her syntax would be something like:

event.dataTransfer.setData("text/plain", ev.target.id);

It would be to transfer drag data, but transfer what data and where? in the above example I am setting a data with the setData, but this data will go where to a variable? Already the part text/plain are keywords that I should use that are defined in the language itself of Javascript or I can create my own?

1 answer

3


DataTransfer is used to store data that is being dragged during a Drag and Drop operation, and can save one or more types of data.

Each object DataTransfer contains an item property, which is a list of objects DataTransferItem. An object DataTransferItem represents a single drag item, each with a type property and a type property for the mimetype type of the data item. The object DataTransferItem also has methods to get the drag item data .stringfile. For example, you can drag data from the desktop to the browser.

  • Thanks a lot, pal! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.