是否可以在两个 JQuery 插件之间传递数据?

发布于 2024-10-12 17:34:00 字数 786 浏览 2 评论 0原文

我有两个自己的 jquery 插件,这两个插件创建的元素有自己的 z-index 值。例如:

// auto increase the z-index value 
// auto increase the z-index to the maximum of their own when I drag it.

element1 created by plugin1 and has the z-index:1;
element2 created by plugin1 and has the z-index:2;
....

// auto increase the z-index value 
// auto increase the z-index to the maximum of their own when I drag it.

element2 created by plugin2 and has the z-index:1;
element2 created by plugin2 and has the z-index:2;
.....

并且它们都可以可拖动,所以当我点击其中一个时,我希望它的 z-index 值成为我创建的所有元素的最大值。但是现在 z-index 分开了!

我正在使用 JQuery UI 可拖动插件,但不喜欢堆栈选项

非常感谢!!

I have two jquery plugin of my own and the elements created by the two plugin had its own z-index value.E.g:

// auto increase the z-index value 
// auto increase the z-index to the maximum of their own when I drag it.

element1 created by plugin1 and has the z-index:1;
element2 created by plugin1 and has the z-index:2;
....

// auto increase the z-index value 
// auto increase the z-index to the maximum of their own when I drag it.

element2 created by plugin2 and has the z-index:1;
element2 created by plugin2 and has the z-index:2;
.....

and both of them can be draggable,so when I click one of them I want its z-index value to be the maximum of all the elements I created.But now the z-index were separated!

I am using JQuery UI draggable plugin but don't like the stack option !

Thank you very much!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2024-10-19 17:34:00

使用名称空间

尝试在插件 1 中
你可以定义

var Plugin1 = {}; //data abuot the plugin
Plugin1.element1 = {}; //data about the element
Plugin1.element1.zindex = 1000; //data about the element

这个可以在js的任何部分检索
但请确保其在 document.ready 之前定义

Try using name spaces

for eg in plugin 1
you can define

var Plugin1 = {}; //data abuot the plugin
Plugin1.element1 = {}; //data about the element
Plugin1.element1.zindex = 1000; //data about the element

This can be retrieved in any part of the js
but make sure its defined before document.ready

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文