简体   繁体   English

Jquery.min.js冲突

[英]Jquery.min.js conflict

My site has a problem when I use the following type function located in the header: 当我使用标题中的以下类型函数时,我的网站出现问题:

<script>
    $(document).ready(function() {
    $('#showVolunteer').click(function() {
        $('.vol_info').slideToggle("fast");
    });
});
</script>

I have to include the following line of code in order to get it to do what I want within the site: 我必须包含以下代码行才能使其在网站中执行我想要的操作:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

The above function, is used in the link "How to Volunteer..." on the main page and allows for the expanding and collapsing of data. 上面的功能在主页上的“如何志愿...”链接中使用,并且可以扩展和折叠数据。 However, when I call the jquery.min.js library as I have, it causes the featured content show to stop rotating pictures every six seconds. 但是,当我按我的方式调用jquery.min.js库时,它将导致精选内容显示每六秒钟停止旋转图片。 When I remove the line: 当我删除行时:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

the slide show refreshes normally and the "How to Volunteer..." link STOPS working. 幻灯片将正常刷新,并且“如何志愿者...”链接停止工作。 I cannot get them both working together. 我不能让他们两个一起工作。

I realize that wordpress includes a copy of jquery.js at the following location \\wp-includes\\js\\jquery\\jquery.js which is the non compressed version, but somehow my function above does not recognize what is in this library. 我意识到wordpress在以下位置\\wp-includes\\js\\jquery\\jquery.js jquery.js的副本,这是非压缩版本,但是上述我的函数无法识别该库中的内容。 It only recognizes jquery.min.js when called in the fashion above. 当以上述方式调用时,它仅识别jquery.min.js

My question is, what do I need to do to get the expand and collapse data link working on the front page TOGETHER with the featured content rotator changing the picture every few seconds? 我的问题是,要使展开和折叠数据链接在首页上正常工作,而特色内容旋转器每隔几秒钟更改一次图片,我该怎么办? In other words BOTH working at the same time. 换句话说,两者都同时工作。

Should I place all my functions (similar to the ones above) in a .js file that is already resident in wordpress? 我是否应该将所有功能(类似于上面的功能)放在已经存在于wordpress中的.js文件中?

thanks 谢谢

This question has been resolved. 这个问题已经解决。 Apparently, you're not suppose to use the $ symbol in Wordpress .js files, as it is used by other libraries and causes confusion within calls to jQuery. 显然,您不应该在Wordpress .js文件中使用$符号,因为它被其他库使用,并且会导致对jQuery的调用混乱。 Instead, you have to use " jQuery " in place of the " $ " symbol. 相反,您必须使用“ jQuery ”来代替“ $ ”符号。 Once this was done, everything worked as it should. 完成此操作后,一切都会按预期进行。

jQuery() NOT $() for Wordpress. jQuery()不是$()用于Wordpress。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM