Friday, December 12, 2025
HomeLanguagesJavascriptscript.aculo.us Drag & Drop revert Option

script.aculo.us Drag & Drop revert Option

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:

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:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32445 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6813 POSTS0 COMMENTS
Nicole Veronica
11951 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12028 POSTS0 COMMENTS
Shaida Kate Naidoo
6946 POSTS0 COMMENTS
Ted Musemwa
7198 POSTS0 COMMENTS
Thapelo Manthata
6892 POSTS0 COMMENTS
Umr Jansen
6881 POSTS0 COMMENTS