4

我有一个可拖动的项目,但是当我拖动它时它位于其他 html 元素下,即使我设置.item_dragable { cursor: move; z-index: 2147483646; } 了事件可拖动:

jQuerydragable.draggable({
    cancel: "a.ui-icon", // clicking an icon won't initiate dragging
    revert: "invalid", // when not dropped, the item will revert back to its initial position
    containment: "document",
    helper: "clone",
    cursor: "move",
    zIndex: 2147483647
});

怎么了?我使用最新的 jQuery 和 jQuery ui

谢谢

4

1 回答 1

4

让您的可拖动项目遍历其他所有内容的最佳方法是使用该选项appendTo(请参阅jQuery UI 文档)并将其设置为"body"

jQuerydragable.draggable({
    cancel: "a.ui-icon", // clicking an icon won't initiate dragging
    revert: "invalid", // when not dropped, the item will revert back to its initial position
    containment: "document",
    helper: "clone",
    cursor: "move",
    zIndex: 100000,
    appendTo: "body"
});

当然,还要设置一个足够大的 z-index,使其高于所有其他值。

于 2012-12-20T09:59:26.047 回答