值
一个表示拖动数据项种类的字符串。它必须是以下值之一:
示例
此示例展示了 kind 属性的使用。
js
function dropHandler(ev) {
console.log("Drop");
ev.preventDefault();
for (const item of ev.dataTransfer.items) {
if (item.kind === "string" && item.type.match("^text/plain")) {
// This item is the target node
item.getAsString((s) => {
ev.target.appendChild(document.getElementById(s));
});
} else if (item.kind === "string" && item.type.match("^text/html")) {
// Drag data item is HTML
console.log("… Drop: HTML");
} else if (item.kind === "file" && item.type.match("^image/")) {
// Drag data item is an image file
const f = item.getAsFile();
console.log("… Drop: File");
}
}
}
规范
| 规范 |
|---|
| HTML # dom-datatransferitem-kind-dev |
浏览器兼容性
加载中…