可能冲突的jQuery库 [英] Possible conflicting jquery libraries
问题描述
我正在使用'reveal modal',它与jquery-1.4.4配合良好.但是,自从添加库以来,该网站的移动版本的弹出"菜单已停止工作.我删除了jquery-1.4.4.库,并且弹出式"菜单再次开始工作,但模式已停止,因此我认为该库存在某些冲突.
I'm using the 'reveal modal' which is working fine with the jquery-1.4.4. library however since adding the library the 'pop-up' menu for the mobile version of the site has stopped working. I removed the jquery-1.4.4. library and the 'pop-up'menu started working again but the modal stopped so I assume there is something conflicting with that library.
我尝试了一段脚本,该脚本允许多个jquery库没有冲突,但是它似乎没有用,所以我认为最简单的方法是重新编写弹出菜单"中的代码.一种不冲突的方式,但我不确定如何.
I have tried a piece of script that allows multiple jquery libraries without conflict but it didn't seem to work so I'm thinking the easiest way is to maybe re-wrtie the code for the 'pop-up- menu in a way that doesnt conflict but i'm not sure how.
我用于弹出菜单的代码如下. (菜单仅显示在移动设备尺寸上,因此您可能必须减小浏览器的宽度)
The code I'm using for the pop-up' menu is as follows. (the menu only shows up on mobile size so you may have to decrease the width of your browser)
$(function() {
var pull = $('.pull');
menu = $('.navigation ul');
menuHeight = menu.height();
$(pull).on('click', function(e) {
e.preventDefault();
menu.slideToggle();
});
$(window).resize(function(){
var w = $(window).width();
if(w > 320 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
});
显示模式附加到索引页面上的问号按钮,URL为 mike-griffin. com/index.html (问号按钮位于桌面尺寸的网站上,因此浏览器的宽度必须大于481px.
The reveal modal is attached to the question mark button on the index page and the url is mike-griffin.com/index.html (the question mark button is on the desktop size site so browser width will need to be above 481px.
推荐答案
使用以下内容可以解决您的问题:
Using the following should solve your issue:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
//code that uses 1.10.2 should be enclosed as follows right after loading 1.10.2
jQuery(function( $ ) {
//1.10.2 code goes here
});
</script>
<script src="js/jquery-1.4.4.min.js"></script>
<script>
//code that uses 1.4.4 should be enclosed as follows
jQuery(function( $ ) {
//1.4.4 code goes here
});
</script>
这篇关于可能冲突的jQuery库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!