Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在interact.js拖动项目中添加自定义右键单击_Jquery_Interact.js - Fatal编程技术网

Jquery 在interact.js拖动项目中添加自定义右键单击

Jquery 在interact.js拖动项目中添加自定义右键单击,jquery,interact.js,Jquery,Interact.js,我想在可拖动项目中添加自定义右键单击“发送到前端”和“发送到后端” HTML <div id="drag-1" class="draggable"> <p> You can drag one element </p> </div> <div id="drag-2" class="draggable"> <p> with each pointer </p> </div> 供参考: 提前感谢

我想在可拖动项目中添加自定义右键单击“发送到前端”和“发送到后端”

HTML

<div id="drag-1" class="draggable">
  <p> You can drag one element </p>
</div>
<div id="drag-2" class="draggable">
    <p> with each pointer </p>
</div>
供参考:


提前感谢。

您可以在此处看到它正在工作:

通过更改元素的
z-index
,可以轻松实现“发送到前面”或“发送到后面”。具有更大
z-index
值的元素将位于顶部

例如:在
#element2
上方发送
#element1

$('#element1').css('z-index', 2);
$('#element2').css('z-index', 1);
请注意,这两个元素都必须将
位置
CSS属性设置为
绝对
固定
相对
。我用了
position:relative(阅读更多)

要实现上下文菜单,有几十个插件可用。我用过这个漂亮的

要使用它,在加载JS库(请参阅我添加的外部引用)后,使用:


是 啊适合2-3个项目。如果我使用ng repeat来显示更多的div(比如10-15),那么解决方案是什么。
$('#element1').css('z-index', 2);
$('#element2').css('z-index', 1);
$(function(){
    $.contextMenu({
        selector: '.context-menu-one', // I've added this class to the element
        callback: function(key, options) {
            // change the z-index values based on "key" value
        },        
        items: {
            "front": {name: "Send to front"},
            "back": {name: "Send to back"}
        }
    });
});