div & drop
div & drop
uplaod file & prevent
dropleave
https://www.runoob.com/jsref/event-ondrop.html
https://www.runoob.com/try/try.php?filename=tryjsref_ondrop
function dragStart(event) {
event.dataTransfer.setData("Text", event.target.id);
document.getElementById("demo").innerHTML = "开始拖动 p 元素";
}
function allowDrop(event) {
// 阻止默认时间
event.preventDefault();
}
function drop(event) {
event.preventDefault();
var data = event.dataTransfer.getData("Text");
event.target.appendChild(document.getElementById(data));
document.getElementById("demo").innerHTML = " p 元素已被拖动";
}
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12166061.html
未经授权禁止转载,违者必究!