javascript - processing drag-n-drop with nested HTML elements? -


i'm using html5 drag , drop, , have drop targets can either empty <div> or a <div> <img> child node.

to make divs drop targets i'm setting ondrop= on divs.

if end drop on div containing image, e.target image node.

if end drop on empty div, e.target div.

to process drop need find id of div, , since e.target can either image or div, i'm checking e.target.parentnode in case don't find information i'm looking in e.target.

is there way can set things e.target div? or looking parentnode chain standard operating procedure?

it old question, answer might someone. use div element below:

<div id="my-div" ondrop="dropped('my-div');">     ... </div> 

you id 'my-div' in dropped if drop happened on child on level.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -