简体   繁体   English

如何让div在html中相互可拖动?

[英]How to make div dragable to each other in html?

<div class="player-tab">
    <div class="img-wrap" draggable="true">
        <img src="assets/player.png" alt="">
    </div>
    <div class="img-wrap" draggable="true">
        <img src="assets/player.png" alt="">
    </div>
    <div class="add-recording"> <a href="#">+ Add Recording</a>

    </div>
</div>

In this code anyone can add recording and a player image show them after add. 在此代码中,任何人都可以添加录制内容,播放器图像在添加后显示。 I want to img-wrap draggable to each other. 我想img-wrap draggable到彼此。

I means I upload 1 record and 2 record. 我的意思是我上传了1条记录和2条记录。 I can sort it to 2nd first and 1st later. 我可以把它排在第2和第1之后。 This way it's can be sorting in format as user want. 这样它就可以按用户需要的格式排序。 Someone know any good idea to implement this feature. 有人知道实现此功能的任何好主意。

You can use jQuery: 你可以使用jQuery:

  $(function() {
    $( "#divid" ).draggable();
  });

see this: http://jqueryui.com/draggable/ 看到这个: http//jqueryui.com/draggable/

I think you want this: 我想你想要这个:

 $(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
 });

check here: http://jqueryui.com/sortable/ 点击这里: http//jqueryui.com/sortable/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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