如何创建以前的变量?

时间:2016-12-23 19:42:42

标签: jquery jquery-ui variables draggable jquery-ui-draggable

我正在尝试创建一个拖放系统,旧的拖动元素会在新的拖动元素进入时返回,但是我在使用上一个变量时遇到了麻烦。这是代码:

//making the objects draggable
for (i = 0; i <= 9; i++) {
    $("#" + i + "individual").draggable({
        revert: true

    });
}
//creating the drop area
$(".music-player").droppable({
    drop: handleDropEvent
});

function handleDropEvent(event, ui) {
    var draggable = ui.draggable;
    var currentID = ui.draggable.attr('id');
    var current = currentID.slice(0, -10); //creating id for current draggable
    ui.draggable.draggable('option', 'revert', false);
    ui.draggable.position({
        of: $(this),
        my: 'left top',
        at: 'left top'
    });
    ui.draggable.css('zIndex', '999');

    $("p").html(previous);//using this to test if works

    var previous = current;//creating the previous variable



}

有关如何解决此问题的任何想法?

0 个答案:

没有答案