kumarappan ramasamy kumarappan ramasamy - 5 days ago 6
CSS Question

How to get the id of the element by using hover droppable function

How to get the ID of the element by hover Droppable function?

enter image description here

I want to get the drag-n-drop id hover on indent icon. Can anybody help me solve this?



$("ul li").droppable({

over: function(event, ui) {

var drag_id = ui.draggable.attr('id');

$("#"+drag_id).css({
"background":"#fff","border-top":"1px solid #333","border-bottom":"1px solid #333"
});
},
drop: function(event, ui) {

var drag_id = ui.draggable.attr('id');
var target_id = event.target.id;

$("#"+drag_id).css({
"background":"#fff","border-top":"1px solid #333","border-bottom":"1px solid #333"
});
setInterval(function(){
$("#"+drag_id).css({
"border-top":"","border-bottom":""
});
}, 2000);
var from_pos = drag_id;
var to_pos = target_id;
changepositions(from_pos,to_pos);
// existing stuff
}
});




Answer

If you look in over it has an event parameter from that you can get it's target then it id like this

$('#droppable').droppable({

    over: function(event, ui) {

      var drop_id = event.target.id; //<-- 5
      alert(drop_id);

      var drag_id = ui.draggable.attr('id');
      alert(drop_id);                //<-- 6

      //other stuff
    },

   //.. other stuff

});
Comments