简体   繁体   English

jQuery与CSS拖放

[英]Jquery drag and drop with css

Working Demo: http://jsfiddle.net/PWh2L/78/ 工作演示: http : //jsfiddle.net/PWh2L/78/

$( ".droppable,.droppable1" ).sortable({
    connectWith: '.droppable,.droppable1',
    revert: 200,
    tolerance:'pointer',
    start: function(){

    },
    stop: function(event,ui){
    if ($(ui.item).hasClass('number1') && $(ui.item).parent()[0].id==="main_list" && $(ui.placeholder).parent()[0] != this) {

            $(this).sortable('cancel');

        }else if ($(ui.item).hasClass('number2') && $(ui.item).parent()[0].id=="main_list1" && $(ui.placeholder).parent()[0] != this){

            $(this).sortable('cancel');

        }
    },
    zIndex: 10
}).droppable({
    drop: function(ev, ui) {



     }
});

在此处输入图片说明

Above link is my code, I had faced one issue which is that when I drag the element (testinggggg) from B to C , then I tried to drag the element (testingggg) from C to A , then it will auto back to C , but when the element (testinggg) go back to C , it will fix it in the top, what I want is every element go back to C it will appear below Name: C , which mean that Name: C will fix it on top. 上面的链接是我的代码,我遇到了一个问题,就是当我将元素(testinggggg)B拖动到C时 ,我试图将元素(testinggggg)C拖动到A ,然后它将自动回到C ,但是当元素(testinggg)返回C时 ,它将固定在顶部,我想要的是每个元素返回C ,它将出现在Name:C下面,这意味着Name:C会将其固定在顶部。

Please advise. 请指教。 :( :(

Just add c in span 只需在范围内添加c

<span class="curtem">C</span>

Here is the working code: http://jsfiddle.net/PWh2L/84/ 这是工作代码: http : //jsfiddle.net/PWh2L/84/

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

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