Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.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
Javascript 将jquery.on与两个不同的jquery实例一起使用_Javascript_Jquery - Fatal编程技术网

Javascript 将jquery.on与两个不同的jquery实例一起使用

Javascript 将jquery.on与两个不同的jquery实例一起使用,javascript,jquery,Javascript,Jquery,我有元素选择器,我想使用jquery。但我不想破坏页面中已经存在的jquery实例。因此,我将我的实例的jQuery重命名为另一个jQuery,在使用之前一切都正常 anotherJquery(“body*:not(.sg_ignore)”).on(“单击“,{'self':this},this.sgMousedown”) 在此之后,所有单击事件都会转到我的jquery实例,即使在以下情况下: anotherJquery ("body *").off("click", { 'self': thi

我有元素选择器,我想使用jquery。但我不想破坏页面中已经存在的jquery实例。因此,我将我的实例的jQuery重命名为另一个jQuery,在使用之前一切都正常

anotherJquery(“body*:not(.sg_ignore)”).on(“单击“,{'self':this},this.sgMousedown”)

在此之后,所有单击事件都会转到我的jquery实例,即使在以下情况下:

anotherJquery ("body *").off("click", { 'self': this }, this.sgMousedown);
如何避免这种行为?

来自jquery手册

如果出于某种原因加载了两个版本的jQuery(这不是 建议),从第二个版本调用$.noConflict(true)将 将全局范围的jQuery变量返回到第一个 版本


尝试使用
$。noConflict(true)

由于一个插件,您需要两个版本吗?如何
break
jquery实例?我需要两个版本,因为我测试了一个版本的代码,页面可能包含另一个版本。至于jquery中的“break”函数可能已被弃用或改变行为。因此,我无法更改jquery的页面版本。您应该使用相同的版本进行测试。我希望在任何页面上插入选择器。我尝试了,但没有帮助。