xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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 元素已被拖动";
}


posted @ 2020-01-08 13:19  xgqfrms  阅读(224)  评论(2编辑  收藏  举报