Horje
How to Do the Drop - ondrop

When the dragged data is dropped, a drop event occurs.

In the example above, the ondrop attribute calls a function, drop(event):


Example of Doing the Drop - ondrop

index.html
Example: HTML
<script>
function drop(ev) {
  ev.preventDefault();
  var data = ev.dataTransfer.getData("text");
  ev.target.appendChild(document.getElementById(data));
}
</script>

Output should be:

Example of Doing the Drop - ondrop

Code explained: (Doing the Drop - ondrop)






Category:
Web Tutorial
Sub Category:
HTML Drag and Drop API
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference