我想做一个带有一些菜单的侧边栏,菜单应该可以拖放!
代码如下:
<div class="sidebar" ondrop="drop(event)" ondragover="allowDrop(event)">
<div class="about" draggable="true" ondragstart="drag(event)" id="about">
<div class="top"><p>about us</p></div>
<p class="about"></p>
</div>
<div class="contact" draggable="true" ondragstart="drag(event)" id="contact">
<div class="top"><p>contact us</p></div>
<form class="contact" action="script/mail.php" method="post" target="ifrm">
//Some INPUT
</form>
<div class="clear"></div>
</div>
</div>
拖放现在运行良好,但也可以将“关于我们”和“联系我们”拖到彼此或表单输入中,我想禁用它!!! 我应该怎么做?
最佳答案
了解 event bubbling ,然后检查 drop()
和 allowDrop()
函数中的 event.target
。
关于HTML 5 拖放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13714106/