Skip to content

Instantly share code, notes, and snippets.

@ada-lovecraft
Last active December 16, 2015 20:00
Show Gist options
  • Save ada-lovecraft/5489617 to your computer and use it in GitHub Desktop.
Save ada-lovecraft/5489617 to your computer and use it in GitHub Desktop.
Grab text data from dropped item.
$("#dropTarget")
.bind("dragover", false)
.bind("dragenter", function(e) {
// add the "activeDrag" class when dragenter is detected
$(this).addClass('activeDrag');
})
.bind("drop", function(e) {
e.preventDefault();
// grab the text data from the dropped item
var dragData = e.originalEvent.dataTransfer.getData("text") ||
e.originalEvent.dataTransfer.getData("text/plain");
// do something with the data
{ ... }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment