JimTEFL Posted December 4, 2013 Share Posted December 4, 2013 I can drag and drop draggable elements onto targets but need to compare the source div with the target div so that I can control where I drop the dragged element. The drag/drop functions identify the target divs but not the source divs. I want to be able to compare as follows: There are 32 target divs. Let the draggable element be on source div6. It can be moved onto div2, div3, div10 or div11, so:- if(div6 - targetdiv == -2 or -3 or 4 or 5) {return;} [to allow a valid drop] else {return:false;} [to prevent invalid drop] How can I identify the source div, please, to control my drag drops? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 4, 2013 Share Posted December 4, 2013 Typically when dragging starts you would save the object being dragged in a global variable. If there is a drop event then it should have references to both elements in the event object for modern browsers. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now