Home > Software engineering >  How to get the type of the dragged item (file or text) when the dragover event fires?
How to get the type of the dragged item (file or text) when the dragover event fires?

Time:02-10

I have a textarea that detects if an element (e. g. image file) is dragged over it.

// drag and drop for upload
$('body').on('dragover', 'textarea', function(e) 
{
    e.preventDefault();
    e.stopPropagation();
    
    // indicator for user
    $('.drophere').show();
});

The problem is that the indicator to drop shows also up when text is dragged over the textarea (and not a file).

I thought I could check the type of the dragged item.

The enter image description here

Where can I find the file type or plain/text type?

CodePudding user response:

  •  Tags:  
  • Related