简体   繁体   English

Javascript拖放测试

[英]Javascript drag and drop test

I'm trying out a little feature with JQuery that I haven't seen before, and I'm not exactly sure how to handle it, so I'm asking to see if any of you know a clever way to pull it off: 我正在尝试使用JQuery的一个以前从未见过的小功能,而且我不确定如何处理它,所以我想看看你们中是否有人知道如何实现此功能:

We have a few elements floating left, in a row, held in a containing div and our jquery UI function call: 在包含div和我们的jquery UI函数调用中,我们连续向左浮动了一些元素:

$(function() {
    $(".container_element" > div ).draggable();
});

markup: 标记:

<div class="container_element">
    <div style="float:left; width:50px; height:50px;">1</div>
    <div style="float:left; width:50px; height:50px;">2</div>
    <div style="float:left; width:50px; height:50px;">3</div>
    <div style="float:left; width:50px; height:50px;">4</div>
    <div style="float:left; width:50px; height:50px;">5</div>
</div>

So my question is how can I drag "1" and drop it in between two of the other elements to have it be placed in between them, and actually change position in the DOM, so that it neatly floats left with the row, just like before, but in a new order? 因此,我的问题是如何将“ 1”拖放到其他两个元素之间,以使其放置在它们之间,并实际上更改DOM中的位置,以便它整齐地向左浮动,就像以前,但是以新顺序?

JS Fiddle: http://jsfiddle.net/JzaCg/ JS小提琴: http//jsfiddle.net/JzaCg/

JQuery UI Draggable documentation: http://jqueryui.com/draggable JQuery UI可拖动文档: http : //jqueryui.com/draggable

So, maybe this can't be done with plain JQuery UI. 因此,也许使用纯JQuery UI无法做到这一点。 If not, how? 如果没有,怎么办?

我认为您正在寻找可排序的jQuery UI http://jqueryui.com/sortable/

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

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