Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | ondragend Event Attribute

Improve Article
Save Article
  • Last Updated : 18 Aug, 2022
Improve Article
Save Article

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. 

Supported Tags: It supports all HTML elements. 


<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.



<!-- HTML code to implement ondragend event using drag
and drop event attribute -->
    <title>ondragend Event Attribute</title>
        .box {
            width: 30%;
            height: 50px;
            margin: 20px;
            border: 1px solid black;
            text-align: center;
        /* Function to start dragging */
        function starts_drag(event) {
            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) {
        /* Function to drop the content */
        function drop_event(event) {
            var data = event.dataTransfer.getData("Text");
    <!-- ondragend event starts from here -->
    <div class="box" ondrop="drop_event(event)"
        <p ondragstart="starts_drag(event)"
            ondragend="end_drag(event)" draggable="true" id="gfg">
    <div class="box" ondrop="drop_event(event)"
    <!-- ondragend event complete here -->
    <p id="demo"></p>


Supported Browser: The browser supported by ondragend event attributes are listed below: 

  • Google Chrome 1.0
  • Edge 12.0
  • Internet Explorer 9.0
  • Mozilla Firefox 9.0
  • Safari 3.1
  • Opera 12.0

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!