如果有人可以幫助我,我將不勝感激
這是我的代碼:
`https://jsfiddle.net/m796a3ud/`
我想要做的是從這些影像串列中拖動一個影像并能夠獲得一個可拖動的克隆,當我把它放在盒子里時,它會計算里面有多少影像,它在大多數情況下都很好用但是當我嘗試將克隆的影像拖入和拖出盒子幾次,克隆會自行克隆,這不是我想要的,我非常感謝您的幫助!
謝謝。
uj5u.com熱心網友回復:
你必須呼叫 ui.helper.remove(); 在外出活動中,試試這個:
$(function() {
// document.addEventListener('mousemove', function(event) {
// console.log($(':hover').hasClass('draggable'))
// })
var n = 0;
$( ".draggable" ).draggable({helper: 'clone'});
$( ".wrong" ).draggable();
$( "#droppable" ).droppable({
accept: ".draggable",
drop: function( event, ui) {
console.log(ui.draggable)
console.log($(':hover').hasClass('draggable'))
var new_signature = $(ui.helper).clone().removeClass('draggable');
new_signature.draggable();
$(this).append(new_signature);
if($(new_signature).hasClass("ui-draggable") && !$(new_signature).hasClass("dropped")){
$(new_signature).addClass("dropped draggable")
n ;
$(".count").text("There are " n " divs inside parent box detail.");
}
},
out: function(event, ui) {
ui.helper.remove();
if($(ui.draggable).hasClass("draggable") && $(ui.draggable).hasClass("dropped")) {
$(ui.draggable).removeClass("dropped")
console.log(ui.helper)
}
if( n > 0) {
n--
}
$(".count").text("There are " n " divs inside parent box detail.");
}
});
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/430897.html
