laponac84 Posted February 6, 2013 Share Posted February 6, 2013 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); } }); });//]]> Quote Link to comment https://forums.phpfreaks.com/topic/274113-jquery-get-id-of-swapp-target-div/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.