alabash
alabash

Reputation: 13

How to find elements with jquery when dragging element

I have couple of elements that are boxes, i want when i drag one element above some of the boxes, to get the specific id of the box.I want to get only these id's that my dragging element is being above them.So how can i do such a thing ?

Upvotes: 1

Views: 122

Answers (1)

Uoli
Uoli

Reputation: 93

If you can use JQuery and JQueryUI please take a look at: http://jqueryui.com/demos/droppable/

They have demos and example codes that will probably solve your problems.

Look at this specific example: http://jqueryui.com/demos/droppable/#accepted-elements You can use the over event to notify you when a a dragged item comes in a element:

$(".dropable").bind( "dropover", function(event, ui) {
   console.log(event);
   console.log(ui);
   console.log($(this));
});

If you run this on Chrome you can check on the console when the event is triggered, and what information it contains.

Upvotes: 1

Related Questions