Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

script.aculo.us Drag & Drop revert Option

  • Last Updated : 25 Nov, 2020

This script.aculo.us Drag & Drop revert Option is used returns to its original position when the drag ends. It also specifies whether the reverteffect callback will be invoked when the drag operation stops.

Syntax:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

new Draggable('element', {revert:true});

Values:

  • revert: This value holds two values true and false default it’s false.

Example:



HTML




<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript" src=
        "scriptaculous-js-1.9.0/lib/prototype.js">
    </script>
  
    <script type="text/javascript" src=
        "scriptaculous-js-1.9.0/src/scriptaculous.js">
    </script>
  
    <script type="text/javascript">
        window.onload = function () {
            $A($('draggables').getElementsByTagName('img'))
                .each(function (item) {
                    new Draggable(item, {
                        revert: true,
                        ghosting: true
                    });
                });
  
            Droppables.add('droparea', {
                hoverclass: 'hoverActive',
                onDrop: moveItem
            });
  
            // Set drop area default non cleared. 
            $('droparea').cleared = false;
        }
  
        function moveItem(draggable, droparea) {
            if (!droparea.cleared) {
                droparea.innerHTML = '';
                droparea.cleared = true;
            }
  
            draggable.parentNode.removeChild(draggable);
            droparea.appendChild(draggable);
        
    </script>
  
    <style type="text/css">
        #draggables {
            width: 550px;
            height: 73px;
        }
  
        #gfg {
            width: 550px;
            height: 73px;
        }
    </style>
</head>
  
<body>
    <div id="draggables">
        <img src=
    </div>
</body>
  
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :