值
一個表示拖動資料項種類的字串。它必須是以下值之一:
示例
此示例展示了 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 |
瀏覽器相容性
載入中…