jquery - 拖放到特定的 div 后拖放更改样式

标签 jquery css drag-and-drop

我在以下位置找到了不错的脚本:http://jsfiddle.net/wfG3L/554/ ,它是关于拖放的。

如果我将 .card 类放入 .stackDrop1 或 .stackDrop2 并在放入 #launchPad 后将其归还,我想更改类 .card 的宽度或高度。

谁能帮帮我?我真的很感激。

$("#launchPad").height($(window).height() - 20);
var dropSpace = $(window).width() - $("#launchPad").width();
$("#dropZone").width(dropSpace - 10);
$("#dropZone").height($("#launchPad").height());

$(".card").draggable({
    appendTo: "body",
    cursor: "move",
    helper: 'clone',
    revert: "invalid",
});

$("#launchPad").droppable({
    tolerance: "intersect",
    accept: ".card",
    activeClass: "ui-state-default",
    hoverClass: "ui-state-hover",
    drop: function(event, ui) {
        $("#launchPad").append($(ui.draggable));
    }
});

$(".stackDrop1").droppable({
    tolerance: "intersect",
    accept: ".card",
    activeClass: "ui-state-default",
    hoverClass: "ui-state-hover",
    drop: function(event, ui) {        
        $(this).append($(ui.draggable));

    }
});

$(".stackDrop2").droppable({
    tolerance: "intersect",
    accept: ".card",
    activeClass: "ui-state-default",
    hoverClass: "ui-state-hover",
    drop: function(event, ui) {        
        $(this).append($(ui.draggable));
    }
});

最佳答案

试试这个 CSS:

.stack .card.ui-draggable
{
    background-color:orange;
}

关于jquery - 拖放到特定的 div 后拖放更改样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39805010/

相关文章:

javascript - $.each javascript 函数的内部 HTML 结果

javascript - 循环遍历表中的特定列,跳过第一列

CSS 文本缩进或 block 引用

css - p :schedule - Wrap Text in Cells

javascript - eval 是邪恶的,但它有缺陷吗?

jQuery 查找前面的非祖先元素

css - 5 个流体 DIV 旁边的固定 DIV

jstree - 如何禁用在 jsTree 中移动,但不禁用拖放插件?

javascript - 使用 jQuery UI Draggable 拖动到 iFrame

ios - CCButton 在 touchMoved 实现时不起作用