简体   繁体   中英

jQuery UI droppable not over

Code:

    $("div.layout.lo-content > div.content").droppable(
    {
        over:function(e,ui)
        {
            alert("yes");
            $(this).css("background-color","#FFFFFF");
        },
        drop: function(e, ui)
        {
            $(ui.draggable).appendTo($(this));
            if($(this).hasClass("ui-sortable"))
            {
                $("div.content").sortable('refresh');
            }
        }
    });

As you can see, when an element is dragged on top of the above element, its background colour will change.

Is there a way to make the background colour transparent if the element is not over the droppable container?

Such as:

{
    notover: function(e,ui) { }
}

Try

css

div.layout.lo-content > div.content {
  background-color:transparent;
}

js

  $("div.layout.lo-content > div.content").droppable(
    {
        over:function(e,ui)
        {
            alert("yes");
            $(this).css("background-color","#FFFFFF");
        },
        drop: function(e, ui)
        {
            $(ui.draggable).appendTo($(this));
            if($(this).hasClass("ui-sortable"))
            {
                $("div.content").sortable('refresh');
            }
        },
        out:function() {
            $(this).css("background-color","transparent");   
        }

    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM