jQuery工具冲突问题 [英] Jquery Tools Conflict Issue

查看:75
本文介绍了jQuery工具冲突问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery工具库设计一个网站,用于滚动和标签之类的事情.我使用他们的CDN加载jQuery和工具库.问题是,当我尝试使用自己的jQuery时,它不起作用&;更具体地说,冲突在于使用jQuery fadeOut时.我的代码位于此页面的顶部 http://www.nicklansdell.com/sample/about .html 并在单击锚标记时淡出整个内容部分.

我已经剥离了Jquery工具库,并用标准的Jquery 1.3.2替换了它,并且我的代码工作正常.

我的问题确实是,有人知道为什么发生这种冲突吗?还是有人遇到过类似的问题?

非常感谢.

我将代码修改为如下形式:

$(function() {
 $("#show-background").click(function () {
  var c = $("#content-area");
  o = (c.css('opacity') == 0) ? 1 : 0;
  c.animate({opacity: o}, 'slow'); 
 });
});

I am designing a website using the jQuery Tools library for things like scrolling and tabs. I using their CDN to load jQuery and the Tools library. The problem is when I try to use some of my own jQuery it does not work & more specifically the conflict lies when using jQuery fadeOut. My code lies at the top of this page http://www.nicklansdell.com/sample/about.html and simply fades out the entire content section when a anchor tag is clicked.

I have stripped out the Jquery Tools Library and replaced it with standard Jquery 1.3.2 and my code works fine.

My question is really, does anybody know why this conflict is happening? Or has anybody had similar issues?

Many thanks in advance.

解决方案

Toggle does't work with opacity this way, it has to be a value between 0 and 1 (because you aren't loading in jQuery version 1.4 which supports 'toggle'):

$(function()
 $("#show-background").click(function () {
  $("#content-area").animate({opacity: 'toggle'}, 'slow'); 
 });
});

I would modify the code to something like this:

$(function() {
 $("#show-background").click(function () {
  var c = $("#content-area");
  o = (c.css('opacity') == 0) ? 1 : 0;
  c.animate({opacity: o}, 'slow'); 
 });
});

这篇关于jQuery工具冲突问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆