Jump to content

jQuery get ID of swapp (target) div


laponac84

Recommended Posts

With the help of code that I listed below, can successfully show ID drag div

 

drag = $('.ui-draggable').attr('id');

alert(drag);

 

But, how to show ID of target(spapped) div (div where drag div is dropped)

 

hiar is all code

//<![CDATA[ 
$(window).load(function(){
jQuery.fn.swap = function(b){ 
  b = jQuery(b)[0]; 
  var a = this[0]; 
  var t = a.parentNode.insertBefore(document.createTextNode(''), a); 

  b.parentNode.insertBefore(a, B); 
  t.parentNode.insertBefore(b, t); 
  t.parentNode.removeChild(t); 
  alert(a);


  return this; 
};


$( ".dragdrop" ).draggable({ revert: true, helper: "clone" });


$( ".dragdrop" ).droppable({
   accept: ".dragdrop",
   activeClass: "ui-state-hover",
   hoverClass: "ui-state-active",
   drop: function( event, ui ) 
{

       var draggable = ui.draggable, 
           droppable = $(this),
           dragPos = draggable.position(), 
           dropPos = droppable.position();

var drag = $('.ui-draggable').attr('id');


       draggable.css({
           left: dropPos.left+'px',
           top: dropPos.top+'px'
       });
       droppable.css({
           left: dragPos.left+'px',
           top: dragPos.top+'px'
       });
       draggable.swap(droppable);



   }
});
});//]]>  

Link to comment
https://forums.phpfreaks.com/topic/274113-jquery-get-id-of-swapp-target-div/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.