DragEvent.dataTransfer
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
DataEvent.dataTransfer
属性保存着拖拽操作中的数据(作为一个 DataTransfer 对象)
This property is 只读 .
语法
var data = dragEvent.dataTransfer;
返回值
data
-
DataTransfer
对象包含着drag event's data
.
示例
这个例子展示了在dragend
事件处理程序中获取拖拽中数据的方式。
js
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 |
---|
HTML Standard # dom-dragevent-datatransfer-dev |
浏览器兼容性
BCD tables only load in the browser