javascript jquery文件冲突如何检测?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4517078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 13:58:56  来源:igfitidea点击:

jquery files conflicts how to detect?

javascriptjquery

提问by Anyname Donotcare

Q:i have a general problem ,when i wanna to do some thing and i find the jquery file which can do exactly what i wanna to do . after a while i need another case and i find that another jquery file serve me and fix my problem .after i add set of jquery files i find conflicts among those files and some features does not work or work in awkward manner ..and when i try to find which file exactly the source for those problems i find myself in closed circle cannot modify this file or cannot delete this file or cannot find that file itself at all.sometimes the file like this:

问:我有一个普遍的问题,当我想做某事时,我发现 jquery 文件可以完全完成我想做的事情。过了一会儿,我需要另一个案例,我发现另一个 jquery 文件为我服务并解决了我的问题。在我添加了一组 jquery 文件后,我发现这些文件之间存在冲突,并且某些功能不起作用或以笨拙的方式工作..当我尝试找到哪个文件正是这些问题的源头,我发现自己处于封闭的圈子中无法修改此文件或无法删除此文件或根本无法找到该文件本身。有时文件是这样的:

<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.js" type="text/javascript"></script>

<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.js" type="text/javascript"></script>

cannot modify it.

不能修改它。

the problem has many faces,and i cannot really know how to handle the whole matter from the beginning.

这个问题有很多方面,我真的不知道如何从一开始就处理整个问题。

can any one give me instructions ,advices,notes, or explanation to prevent the problem from the beginning and how to fix it if it was happened.

任何人都可以给我说明、建议、注释或解释,以从一开始就防止出现问题以及如果发生问题如何解决。

回答by vedvrat13

Please have only one instance of Jquery Library. The library has the capability to solve the issues. Seperate instances or files will confuse the code. I hope this helps.

请只有一个 Jquery 库实例。图书馆有能力解决这些问题。单独的实例或文件会混淆代码。我希望这有帮助。

回答by Matt Asbury

If you point your browser at http://jqueryjs.googlecode.com/files/jquery-1.3.jsit will give you the JS file for you to download and save as your own copy. You can then change it as you want and link it in your website rather than use the one located at googlecode.com.

如果您将浏览器指向http://jqueryjs.googlecode.com/files/jquery-1.3.js,它将为您提供 JS 文件供您下载并另存为您自己的副本。然后,您可以根据需要更改它并将其链接到您的网站,而不是使用位于 googlecode.com 的那个。

回答by clklachu

http://api.jquery.com/jQuery.noConflict/

http://api.jquery.com/jQuery.noConflict/

This link suggests few of the ways to avoid the jQuery conflict. Please check that as it could give you some more idea to resolve your problem.

此链接建议了一些避免 jQuery 冲突的方法。请检查一下,因为它可以为您提供更多解决问题的想法。

Regards, Lakxman Kumar C

问候, Lakxman Kumar C