Code explained: (Doing the Drop - ondrop)
- Call preventDefault() to prevent the browser default handling of the data (default is open as link on drop)
- Get the dragged data with the dataTransfer.getData() method. This method will return any data that was set to the same type in the setData() method
- The dragged data is the id of the dragged element ("drag1")
- Append the dragged element into the drop element
Category: | Web Tutorial |
Sub Category: | HTML Drag and Drop API |
Uploaded by: | Admin |