0
我想写一个进度指示器代码来显示一个任务完成了多少。我正在尝试使用jQuery UI的拖放功能。需要移动的项目位于左侧。当它们在右侧的绘图区域拖动时,计数器需要在放下时更新。它只需要计算移动的物品数量,而不是每个物品移动到网格区域$(“#grid”)的次数。drag item item w/jQuery
我觉得我很接近但还没有那么完美。下面是我到目前为止有:
var startCount = $("#launchPad .card").length;
var moveFromLaunch = false;
$(".card").bind("dragstart", function(event, ui) {
moveFromLaunch = true;
});
$("#dropZone").bind("drop", function(event, ui) {
var currentCount = $("#launchPad .card").length;
if (moveFromLaunch)
currentCount--;
currentCount = startCount - currentCount;
moveFromLaunch = false;
var progress = Math.floor(currentCount/startCount * 100);
$("#progBarRd").width(progress);
$('#progBar').attr("title", progress+'%');
});
你是什么意思?我使用$(“#launchPad .card”)。计算#launchPad中剩余的项目... – santa