M
M
Monty Python2018-02-01 16:10:07
JavaScript
Monty Python, 2018-02-01 16:10:07

Drag and Drop default value?

In the second line ev.preventDefault(); prevent the handler from working by default, it is not clear what it does by default

function allowDrop(ev) {
    ev.preventDefault();
}

function drag(ev) {
    ev.dataTransfer.setData("text", ev.target.id);
}

function drop(ev) {
    ev.preventDefault();
    var data = ev.dataTransfer.getData("text");
    ev.target.appendChild(document.getElementById(data));
}

5a79d39706a79280141123.jpeg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question