HTML | ondragend Event Attribute
The ondragend event attribute works when the user finished the dragging of element. The drag and drop feature is common in HTML5. Any element can make draggable by using the HTML5 draggable attribute.
Syntax:
<element ondragend = "script">
Attribute Value: This event contains single attribute script which works when ondragend event called.
Note: Images and links are by default draggable.
Example:
<!-- HTML code to implement ondragend event using drag and drop event attribute --><!DOCTYPE HTML> <html> <head> <title>ondragend Event Attribute</title> <style> .box { width: 30%; height: 50px; margin:20px; border: 1px solid black; text-align:center; } </style> <script> /* Function to start dragging */ function starts_drag(event) { event.dataTransfer.setData("Text", event.target.id); document.getElementById("demo").innerHTML = "Dragging is in work"; } /* Function to stop dragging */ function end_drag(event) { document.getElementById("demo").innerHTML = "Dragging works properly"; } /* Function to allow drop content */ function drop_allow(event) { event.preventDefault(); } /* Function to drop the content */ function drop_event(event) { event.preventDefault(); var data = event.dataTransfer.getData("Text"); event.target.appendChild(document.getElementById(data)); } </script> </head> <body> <!-- ondragend event starts from here --> <div class="box" ondrop="drop_event(event)" ondragover="drop_allow(event)"> <p ondragstart="starts_drag(event)" ondragend="end_drag(event)" draggable="true" id="gfg">GeeksforGeeks<p> </div> <div class="box" ondrop="drop_event(event)" ondragover="drop_allow(event)"></div> <!-- ondragend event complete here --> <p id="demo"></p> </center> </body> </html> |
Output:

Supported Browser: The browser supported by ondragend event attributes are listed below:
- Google Chrome 4.0
- Internet Explorer 9.0
- Mozila Firefox 3.5
- Safari 6.0
- Opera 12.0
Recommended Posts:
- HTML | DOM ondragend Event
- HTML | onwheel Event Attribute
- HTML | ondragleave Event Attribute
- HTML | onmouseup Event Attribute
- HTML | oninput Event Attribute
- HTML | ondblclick Event Attribute
- HTML | onload Event Attribute
- HTML | onmousemove Event Attribute
- HTML | oncontextmenu Event Attribute
- HTML | onsubmit Event Attribute
- HTML | onfocus Event Attribute
- HTML | onselect Event Attribute
- HTML | onoffline Event Attribute
- HTML | onsearch Event Attribute
- HTML | onmouseover Event Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



