DataTransfer object in HTML5

The event listener methods for all the drag and drop events accept Event object that has a readonly attribute called dataTransfer. The event.dataTransfer returns DataTransfer object associated with the event as follows:

function EnterHandler(event) {
   DataTransfer dt = event.dataTransfer;
   ?
}

You can try to run the following code to implement DataTransfer object:


   
      

      
   

   
      
         

Drag and drop HTML5 demo

         
Try to drag the purple box around.
         
           

Drag Me

         
         
Dustbin
     
   
Updated on: 2020-01-29T08:20:22+05:30

438 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements