How to get container of draggable inside drop event?

I have an html like this:

<div id="container1">
    <div class="dragme">drag me</div>
</div>
<div id="container2">
    <div class="dragme">drag me</div>
</div>
<div id="droponme"></div>

$(".dragme").draggable();
$("#droponme").droppable({
    accept: ".dragme",
    drop: function(e, u) { alert( /* find id of the container here*/ ); };
});

I want to find the container of the draggable object on drop event handler. How can I do this?

Answers


$(".dragme").draggable();
$("#droponme").droppable({
    accept: ".dragme",
    drop: function(e, u) {
        alert(u.draggable.parent().attr('id') );
        // in your example: container1 or container2
    }
});

Need Your Help

Create array of values from sub-table

sql arrays postgresql join plpgsql

For example I have table users(id, name, email). There is table photos (id, value)

How to parse JSON file in android? JSON file is located in WAMP server.Not able to do

android json localhost wampserver

I am doing JSON parsing in android application. and I want to parse JSON file which is located in WAMP server. I m passing url of JSON file. I do not have any error in android code but I do not kno...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.