如何在JavaScript中处理拖放事件?

时间:2016-01-09 13:47:34

标签: javascript javascript-events

我使用javaScript并且不知道如何处理拖放事件。任何帮助将不胜感激。 thnx提前..

1 个答案:

答案 0 :(得分:0)

阅读本文:https://developer.mozilla.org/en-US/docs/Web/Events/drag

    /* events fired on the draggable target */
    document.addEventListener("drag", function(event) {

    }, false);

    document.addEventListener("dragstart", function(event) {

    }, false);

    document.addEventListener("dragend", function(event) {

    }, false);

    /* events fired on the drop targets */
    document.addEventListener("dragover", function(event) {

    }, false);

    document.addEventListener("dragenter", function(event) {

    }, false);

    document.addEventListener("dragleave", function(event) {

    }, false);

    document.addEventListener("drop", function(event) {

    }, false);