Skip to content
Related Articles

Related Articles Drag & Drop greedy Option

View Discussion
Improve Article
Save Article
  • Last Updated : 09 May, 2022
View Discussion
Improve Article
Save Article

This Drag & Drop greedy Option is used to stops processing hovering other droppable, under the drag-gable won’t be searched. The default value of this option is true, that means the drop area will accept the draggable element false won’t.


Droppables.add('element', {greedy: false or true});



<!DOCTYPE html>
    <script type="text/javascript"
    <script type="text/javascript"
    <script type="text/javascript">
        window.onload = function () {
                'img')).each(function (item) {
                    new Draggable(
                        item, { revert: true, ghosting: true });
                'droparea', {
                    hoverclass: 'hoverActive',
                greedy: false, onDrop: moveItem
            // Set drop area default non cleared.
            $('droparea').cleared = false;
        function moveItem(draggable, droparea) {
            if (!droparea.cleared) {
                droparea.innerHTML = '';
                droparea.cleared = true;
    <style type="text/css">
        #draggables {
            width: 550px;
            height: 73px;
        #gfg {
            width: 550px;
            height: 73px;
        #droparea {
            float: left;
            width: 650px;
            height: 90px;
            border: 2px solid gray;
            text-align: center;
            font-size: 16px;
            padding: 12px;
        <h1 style="color: green">
        <p>A Computer Science Portal for Geeks</p>
    <strong> Drag & Drop
        greedy Option
    <div id="draggables">
        <img src="gfg.png">
        <img src="gfg1.png">
    <div id="droparea">
        Drag the Image and Drop Your
        Image in this area


  • Before drag and drop:
  • After drag and drop: Drop area won’t accept the element.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!