简体   繁体   中英

drag and drop div onto div

I am not sure how to ask this question, but I'll try my best.

I am coding a website, and I have a list of div's that are generated with php. There is another div on the side. The idea is, when you drag one of the divs in the list onto the other div, it will do something with the class of the div in the list.

The HTML code for one of the divs in the list:

<div style='width:100px' class='div1' draggable='true'>
[content]
</div>

The HTML code for the div you drop it into:

<div class="dropzone" ondrop="drop(event)" ondragover="allowDrop(event)" style="padding: 10px; border-width: 2px; border-style: dashed; width: 100px; height: 210px; float: right;">
[content]
</div>

The idea is, when you drag "div1" into "dropzone", dropzone will run a javascript function with "div1" as a variable. Is there a way to do this in javascript?

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM