The HTML ondragover attribute is an event handler that triggers a script to execute when a draggable element is dragged over a valid drop target.
Definition and Usage
➔ By default, elements cannot accept drops. To enable or accept dropping, you need to override the browser's default handling behavior.
➔ This is usually done by calling event.preventDefault() within the event handler function on the target elements.
➔ The ondragover event is fired continuously as a draggable item moves over a potential drop target.
➔ Events are fired on draggable items that will be dragged to the target.
- ondragstart - This is fired when the user begin to drag an element.
- ondrag - This is fired when an element is being dragged.
- ondragend - This is fired when the user has complete dragging the element.
➔ Events fired on the drop targets where the item can be dropped.
- ondragenter - This is fired when the dragged element enters the drop target.
- ondragover - This is fired when the dragged element is over the drop target.
- ondragleave - This is fired when the dragged element leaves the drop target.
- ondrop - This is fired when the dragged element is dropped on the drop target.
Applies to
This attribute can be used on the following element.
| Attribute | Element |
|---|---|
| ondragover | All visible elements |