我对使用拖放感到困惑。到目前为止,它可以拖放一个元素。但是,我想在完成放置后存储结构,所以我将放置的目标添加到放置后的父级中,我发现 ondragend 每次调用两次,ondrop 调用基于目标元素的数量. 如何实施?
function drop(){
//this function is called base on the numbers of target element
//drop third into first/second will be called once
//drop second into first and then drop third into second will be called twice
}
function over(){
//this function is called base on the numbers of total affected element
//drop third into first/second will be called twice
//drop second into first and then drop third into second will be called thrice
}
<div ondrop=drop ondragend=over id="first"></div>
<div ondrop=drop ondragend=over id="second"></div>
<div draggable=true id="third"></div>
另外我在 drop 和 over 中都使用 return false 也无法解决问题