两个jquery工具互相干扰
我是 jquery 新手。我正在开发一个使用滚动功能的网站,我发现它可以从一个页面移动到另一个页面,其脚本如下所示:
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="js/jquery.scrollTo.js"></script>
我还有一个脚本,我想在几个页面上使用它,该脚本是图像库的一种 Shadowbox 类型。它的脚本如下所示:
<script type="text/javascript"src="http://cdn.jquerytools.org/1.2.6/full/jquery.tools.min.js"></script>
如果我在页面上有两个脚本,则只有阴影框起作用,而滚动不起作用。如果我将 Shadowbox 脚本关闭,那么滚动就会起作用。 如果我将 Shadowbox 脚本放在滚动脚本上方,则只有滚动有效。
我不确定是否需要提供更多信息来解释我的问题。据我所知,是这些脚本导致了问题并且相互冲突。
I am new to jquery. I am working on a website that uses a scroll function I found to move from page to page its scripts looks like this:
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="js/jquery.scrollTo.js"></script>
I also have a script that I want to use on a few pages that is a type of shadowbox for an image gallery. Its script looks like this:
<script type="text/javascript"src="http://cdn.jquerytools.org/1.2.6/full/jquery.tools.min.js"></script>
If I have both scripts on the page then only the shadowbox works and the scrolling does not. If I take the shadowbox script off then the scrolling does work.
If I put the shadowbox script above the scrolling script then only the scrolling works.
I am not sure if I need to include any more information to explain my problem. From what I can tell it is these scripts that are causing the problem and conflicting with each other.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 jQuerytools,您只需包含它,您就可以免费获得 jQuery 1.6.4 (阅读快速入门,如果需要,您可以从中删除 jquery,请查看快速入门下方)。因此,通过包含 jQuery 1.3.1 以上的 jQuery 工具,您将尝试加载同一工具包的两个不同版本(1.3.1 和 1.6.4),从而相互冲突并导致问题。
删除包含 jquery 1.3.1 的行并尝试。
With jQuerytools, you only need to include it and you get jQuery 1.6.4 for free (read quick start, and you can remove jquery from it if you want, look below the quick start). Therefore, by including jQuery 1.3.1 above jQuery tools, you are trying to load two different versions (1.3.1 and 1.6.4) of the same toolkit, thus conflicting with each other and causing you problems.
Remove the line including jquery 1.3.1 and try that.
我遇到了 jQuery 插件发生冲突的问题。
因此,经过一番研究后,我将这两个脚本加载到 html 文档的头部,位于连续的独立脚本标记区域之间。然后我使用:
window.onload = function() {function01(); function02();};
以有序的方式单独加载每个函数。
这次对我有用。
I had a problem with jQuery plugins clashing somehow.
So after a little research I loaded both scripts into the head of the html document, between consecutive separated script tag zones. Then I used:
window.onload = function() {function01(); function02();};
to load each function in an orderly fashion and separately.
It worked for me this time.