Javascript Jquery冲突导致错误
从事具有多种功能的项目,例如Javascript Jquery冲突导致错误,javascript,jquery-ui,jquery,jquery-plugins,Javascript,Jquery Ui,Jquery,Jquery Plugins,从事具有多种功能的项目,例如 谷歌翻译 图像滑块[使用Gallerific] 弹出窗口[使用阴影框] JavaScript水平菜单栏* 现在我们看到jquery冲突和错误消息,如 我知道当代码找不到jquery文件但文件存在时,会出现此类消息。 I have optimized all these and have included only one jquery file of jquery-1.9.1.min.js but still not able to clear the con
- 谷歌翻译
- 图像滑块[使用Gallerific]
- 弹出窗口[使用阴影框]
- JavaScript水平菜单栏*
I have optimized all these and have included only one jquery file of jquery-1.9.1.min.js but still not able to clear the conflict Here is the sequence used by me
以下是项目中使用的文件列表
这是谷歌翻译所需要的
1.<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
2. <script type="text/javascript" src="//jquery-translate.googlecode.com/files/jquery.translate-1.3.7.min.js"></script>
3. <script type="text/javascript" src="/scripts/jQuery/jquery.cookie.js"></script>
4. <script type="text/javascript" src="/scripts/jquery.bt.js"></script>
5. <script type="text/javascript" src="/scripts/jquery-ui-1.8.21.custom.min.js"></script>
6. <script type="text/javascript" src="/fancybox/jquery.fancybox.pack.js"></script>
7. <script type="text/javascript" src="/scripts/common.js"></script>
但仍然无法得到解决方案
当我删除这个滑块代码时,一切正常,没有错误,但滑块不会工作
<!--script for slider--->
<script type="text/javascript">
jQuery(document).ready(function($) {
// We only want these styles applied when javascript is enabled
$('div.navigation').css({'width' : '', 'float' : 'right'});
$('div.content').css('display', 'block');
// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = 0.67;
$('#thumbs ul.thumbs li').opacityrollover({
mouseOutOpacity: onMouseOutOpacity,
mouseOverOpacity: 1.0,
fadeSpeed: 'fast',
exemptionSelector: '.selected'
});
// Initialize Advanced Galleriffic Gallery
var gallery = $('#thumbs').galleriffic({
delay: 2500,
numThumbs: 15,
preloadAhead: 10,
enableTopPager: true,
enableBottomPager: true,
maxPagesToShow: 7,
imageContainerSel: '#slideshow',
controlsContainerSel: '#controls',
captionContainerSel: '#caption',
loadingContainerSel: '#loading',
renderSSControls: true,
renderNavControls: true,
random: true,
prevLinkText: '',
nextLinkText: '',
nextPageLinkText: '',
playLinkText: '',
pauseLinkText: '',
prevPageLinkText: '',
enableHistory: false,
autoStart: false,
syncTransitions: true,
defaultTransitionDuration: 900,
onSlideChange: function(prevIndex, nextIndex) {
// 'this' refers to the gallery, which is an extension of $('#thumbs')
this.find('ul.thumbs').children()
.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
.eq(nextIndex).fadeTo('fast', 1.0);
},
onPageTransitionOut: function(callback) {
this.fadeTo('fast', 0.0, callback);
},
onPageTransitionIn: function() {
this.fadeTo('fast', 1.0);
}
});
});
</script>
<!--script end--->
jQuery(文档).ready(函数($){
//我们只希望在启用javascript时应用这些样式
$('div.navigation').css({'width':''float':'right'});
$('div.content').css('display','block');
//最初在拇指上设置不透明度并添加
//拇指悬停效果的附加样式
var onMouseOutOpacity=0.67;
$('u#thumbs ul.thumbs li').opacityrollover({
mouseOutOpacity:onMouseOutOpacity,
鼠标不透明度:1.0,
fadeSpeed:“快”,
ExcemptionSelector:“.已选定”
});
//初始化高级Gallerific库
var gallery=$(“#拇指”).gallerific({
延误:2500,
努姆坦布斯:15,
预测:10,
enableTopager:true,
enableBottomPager:正确,
maxPagesToShow:7,
imageContainerSel:“#幻灯片放映”,
controlsContainerSel:“#controls”,
captionContainerSel:“#caption”,
装载集装箱EL:“#装载”,
渲染器控件:true,
renderNavControls:true,
是的,
prevLinkText:“”,
下一个链接文本:“”,
NextPageLink文本:“”,
playLinkText:“”,
PauseLink文本:“”,
prevPageLinkText:“”,
enableHistory:错误,
自动启动:错误,
对,,
默认转换持续时间:900,
onSlideChange:函数(prevIndex、nextIndex){
//“this”指的是gallery,它是$(“#thumbs”)的扩展
this.find('ul.thumbs').children()
.eq(prevenindex).fadeTo('fast',onMouseOutOpacity).end()
.eq(nextIndex).fadeTo('fast',1.0);
},
onPageTransitionOut:函数(回调){
这个.fadeTo('fast',0.0,回调);
},
onPageTransitionIn:函数(){
这是fadeTo('fast',1.0);
}
});
});
有人能帮忙吗?尝试在jQuery中使用
<script src="....../jquery-1.8.3.min.js"></script>
<script type="text/javascript">
var jQuery_1_8_3 = $.noConflict(true);
</script>
<script type="text/javascript" src="...../jquery-1.4.2.js"></script>
<script type="text/javascript">
var jQuery_1_4_2= $.noConflict(true);
</script>
var jQuery_1_8_3=$.noConflict(true);
var jQuery_1_4_2=$.noConflict(true);
我阅读了您的问题,并在网站上搜索了您使用的每个插件
$.noConflict(true)代码>
如果你的项目是服务器,当它为html文件打开时
我建议您在一个html文件中插入对外部div的调用
在每个html文件中,您都可以使用html编写脚本
$(document).ready(function () {
.............
});
不能在每个html文件中调用外部文件,因为这会产生正常冲突
和..
I have optimized all these and have included only one jquery file of jquery-1.9.1.min.js but still not able to clear the conflict Here is the sequence used by me
我建议在这个网站上查找最后的图书馆
和..
I have optimized all these and have included only one jquery file of jquery-1.9.1.min.js but still not able to clear the conflict Here is the sequence used by me
这样比较好
和::
对于错误TypeError:$不是函数
取决于此函数的实现或写入方式。
可能的错误是代码>或{
,}
,(
,)
这是因为加载了另一个javascript库并覆盖了jQuery的对象$()
快捷方式。
因此,当我们包括jquery之外的其他javascript库时,我们将jquery库暴露在冲突中。
许多JavaScript库使用$
作为函数或变量名,就像jQuery一样。在jQuery中,$只是jQuery的别名,因此所有功能都可以在不使用$
的情况下使用。
一种解决方案是,如果我们需要在jQuery旁边使用另一个JavaScript库,我们可以通过调用$.noConflict()
将$
的控制权返回给另一个库,如下所示:
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ follow here.
});
// Code that uses other library's $ follow here.
</script>
假设:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript">
( function($) {
// Assigning $ again to jquery
$(document).ready( function() { alert("Now you can use to use '$' in your jquery code"); } );
} ) ( jQuery );
//this will fail
$(document).ready( function() { alert('This fails because $ has been modified outside jquery'); } );
</script>
榜样
最后
Typeerror for null
看我按照这个流程,错误被解决了不需要任何.noConflict()和on强>
1)<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
2)<script type="text/javascript" src="//jquery-translate.googlecode.com/files/jquery.translate-1.3.7.min.js"></script>
3)<script type="text/javascript" src="/scripts/jQuery/jquery.cookie.js"></script>
4)<script type="text/javascript" src="/scripts/jquery.bt.js"></script>
5)<script type="text/javascript" src="/fancybox/jquery.fancybox.pack.js"></script>
6)<script type="text/javascript" src="/scripts/common.js"></script>
7)<script src="/scripts/jQuery/insert_active_flash.js" type="text/javascript"></script>
8)<script type="text/javascript" src="/SliderBox/js/jquery.galleriffic.js"></script>
9)<script type="text/javascript" src="/SliderBox/js/jquery.opacityrollover.js"></script>
10)<script type="text/javascript" src="/SliderBox/shadowbox/shadowbox.js"></script>
11)<script type="text/javascript" src="/scripts/jquery.als-1.1.min.js"></script>
12)<script type="text/javascript" src="/scripts/settingsEN.js"></script>
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
12)
与prototype.js冲突的精简版javascript。我刚刚删除了prototype.js文件,并按顺序排列了所有参考文件[顺序非常重要]
现在错误被删除了,我仍然想知道prototype.js的实际问题是什么?有用的提示:永远不要看W3!还尝试在jquery-1.9.1.min.js之后移动jquery-ui-1.8.21.custom.min.js。我认为这一行
覆盖了jquery函数(因为它本身有$
函数)。或者我可以在@Swapneel Kondgule获得更多关于错误的详细信息
I have optimized all these and have included only one jquery file of jquery-1.9.1.min.js but still not able to clear the conflict Here is the sequence used by me
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ follow here.
});
// Code that uses other library's $ follow here.
</script>
( function($) {
// Your jquery code
} ) ( jQuery );
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript">
( function($) {
// Assigning $ again to jquery
$(document).ready( function() { alert("Now you can use to use '$' in your jquery code"); } );
} ) ( jQuery );
//this will fail
$(document).ready( function() { alert('This fails because $ has been modified outside jquery'); } );
</script>
$(document) //won't work
jquery(document) //will work
Typeerror for null
1)<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
2)<script type="text/javascript" src="//jquery-translate.googlecode.com/files/jquery.translate-1.3.7.min.js"></script>
3)<script type="text/javascript" src="/scripts/jQuery/jquery.cookie.js"></script>
4)<script type="text/javascript" src="/scripts/jquery.bt.js"></script>
5)<script type="text/javascript" src="/fancybox/jquery.fancybox.pack.js"></script>
6)<script type="text/javascript" src="/scripts/common.js"></script>
7)<script src="/scripts/jQuery/insert_active_flash.js" type="text/javascript"></script>
8)<script type="text/javascript" src="/SliderBox/js/jquery.galleriffic.js"></script>
9)<script type="text/javascript" src="/SliderBox/js/jquery.opacityrollover.js"></script>
10)<script type="text/javascript" src="/SliderBox/shadowbox/shadowbox.js"></script>
11)<script type="text/javascript" src="/scripts/jquery.als-1.1.min.js"></script>
12)<script type="text/javascript" src="/scripts/settingsEN.js"></script>