在jQuery中拖动时,元素不能具有z-index最大值(element cant have z-index maximum when drag in jQuery)

我有一个可拖动的项目,但当我拖动它时,它在其他html元素下,即使我设置.item_dragable { cursor: move; z-index: 2147483646; } .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

谢谢

i have a dragable item but it is under other html element when i drag it, even i set .item_dragable { cursor: move; z-index: 2147483646; } and on event dragable:

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 });

what wrong is it? i use the lastest jQuery and jQuery ui

thanks

最满意答案

让可拖动项目覆盖其他所有内容的最佳方法是使用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指数高于其他所有指数。

The best way to have your draggable item going over everything else is to use the option appendTo (see jQuery UI doc) and set it to "body" like this :

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" });

and of course set a z-index big enough to be higher than all others.

更多推荐