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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.