The DragEvent.dataTransfer
property holds the drag operation's data (as a DataTransfer
object).
This property is Read only .
Syntax
let data = dragEvent.dataTransfer;
Return value
data
- A
DataTransfer
object which contains thedrag event's data
.
Example
This example illustrates accessing the drag and drop data within the dragend
event handler.
function processData(d) {
// Process the data ...
}
dragTarget.addEventListener("dragend", function(ev) {
// Call the drag and drop data processor
if (ev.dataTransfer !== null) processData(ev.dataTransfer);
}, false);
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living StandardThe definition of 'DragEvent.dataTransfer' in that specification. | Living Standard | |
HTML 5.1The definition of 'DragEvent.dataTransfer' in that specification. | Recommendation | Initial definition |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
dataTransfer
|
Chrome
Full support 46 |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 10 |
Opera
Full support Yes |
Safari
Full support 3.1 |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
Full support Yes |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No |
Legend
- Full support
- Full support
- No support
- No support
DragEvent.dataTransfer by Mozilla Contributors is licensed under CC-BY-SA 2.5.