开发者

get Drop Target of component

Hi, I want to get Drop target className/ID after Drop Event. Does anybody tell me how to get ?

<div class="drop_1" id="drop1"></div>

<div class="drop_2" id="drop2"></div>

<div class="drop_3" id="drop3"></div>

all DIV component must be drag-able & drop-ab开发者_开发百科le onto each other


use the this.id inside the drop handler

jsFiddle demo

$( ".selector" ).droppable({
   drop: function(event, ui) {
       console.log(this.id);
   }
});


Example

$(function() {

      ***/* Make draggable */***

        $(".drop_1, .drop_2, .drop_3").draggable();

        var dropOpts = {
        accept:".drop_1, .drop_2, .drop_3",
        drop:dropCallback,
        greedy:true
          };

    /* Droppable */

    $(".drop_1, .drop_2, .drop_3").droppable(dropOpts);

    /*get your Drop target*/

     function dropCallback(e) {
        alert("The firing droppable was " + e.target.className);
        }

    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜