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.
DragEvent.dataTransfer
プロパティは、ドラッグ操作のデータを(DataTransfer
オブジェクトとして)保持します。
このプロパティは 読取専用 です。
値
DataTransfer
オブジェクトで、ドラッグイベントのデータが入ります。
例
この例では、 dragend
イベントハンドラーの中でドラッグ&ドロップデータへアクセスする方法を説明します。
js
function processData(d) {
// データを処理...
}
dragTarget.addEventListener(
"dragend",
(ev) => {
// ドラッグ&ドロップのデータ処理を呼び出す
if (ev.dataTransfer !== null) processData(ev.dataTransfer);
},
false,
);
仕様書
Specification |
---|
HTML # dom-dragevent-datatransfer-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
dataTransfer |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on 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.