I’m dragging an image like it’s done here.
I’m trying to get the id of the div, which I start the dragging process from.
How can I do that?
Thanks.
I’m dragging an image like it’s done here . I’m trying to get the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In the example you linked, the function
drag()is triggered by the onDragStart event of the image node. This event object is passed to theevargument ofdrag(), giving thedrag()function access to the event’s target — that is, the element you’re dragging — viaev.target.Since you have the target, you can access the target’s parent node with
ev.target.parentNode, and you can access the parent node’s ID viaev.target.parentNode.id.