簡體   English   中英

拖動元素的克隆,並使用可排序的jqueryui將其放在div區域中

[英]clone of dragged element and place it in dragged div area using sortable jqueryui

我正在嘗試克隆拖動的元素,並將其放置在拖動的元素以0.2不透明度存在的區域中。 由於某種原因,它不能完美工作。占位符可以移動並顯示放置元素的位置,但是從中拖動元素的區域應顯示不透明度降低的克隆,直到放置元素為止。

js小提琴:

http://jsfiddle.net/Fj7eN/

的HTML:

<div id="sortable">
    <div class="one sortableElems">Div 1</div>
    <div class="two sortableElems">Div 2</div>
    <div class="three sortableElems">Div 3</div>
</div>

jQuery的:

$(function() {      
    $("#sortable").sortable({
        opacity: 0.8,
        cursor:"-webkit-grab",
        placeholder: {
            element: function(item, ui) {
                return item.clone().css({
                    "opacity":"0.2", 
                    "position":"relative"
                });
            },
            update: function() {
                return;
            }
        }
    });
});

自己找到答案:

js小提琴:

http://jsfiddle.net/Fj7eN/5/

jQuery的:

$(function() {  
    $("#sortable").sortable({
        opacity: 0.8,
        cursor:"-webkit-grab",
        start:function(e,ui){
            $(ui.item[0]).css({"display":"block","opacity":"0.2"});
        },
        helper:"clone",
        placeholder: "placeholder",
        update:function(e,ui){
           $(ui.item[0]).css({"opacity":"1"});
        }
    });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM