--- title: DragEvent.dataTransfer slug: Web/API/DragEvent/dataTransfer translation_of: Web/API/DragEvent/dataTransfer ---
DataEvent.dataTransfer
屬性保留了拖曳操作中的資料(指向一個 {{domxref("DataTransfer")}} 物件)。
此屬性為 {{readonlyInline}}。
var data = dragEvent.dataTransfer;
data
This example illustrates accessing the drag and drop data within the {{event("dragend")}} event handler.
function process_data(d) { // Process the data ... } dragTarget.addEventListener("dragend", function(ev) { // Call the drag and drop data processor if (ev.dataTransfer != null) process_data(ev.dataTransfer); }, false);
Specification | Status | Comment |
---|---|---|
{{SpecName("HTML WHATWG", "interaction.html#dom-dragevent-datatransfer", "DragEvent.dataTransfer")}} | {{Spec2("HTML WHATWG")}} | |
{{SpecName("HTML5.1", "editing.html#dom-dragevent-datatransfer", "DragEvent.dataTransfer")}} | {{Spec2("HTML5.1")}} | Initial definition |