Javascript和Jquery冲突
我有一个问题,当我删除下面的代码时,视频播放器弹出式播放器工作,但我的联系方式不工作Javascript和Jquery冲突,javascript,jquery,Javascript,Jquery,我有一个问题,当我删除下面的代码时,视频播放器弹出式播放器工作,但我的联系方式不工作 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> 我已经添加了无冲突的脚本,但它现在仍在工作,下面是我的JS和Jquery代码,它们位于head标记中。任何帮助都将不胜感激 <script type="text
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
我已经添加了无冲突的脚本,但它现在仍在工作,下面是我的JS和Jquery代码,它们位于head标记中。任何帮助都将不胜感激
<script type="text/javascript" src="lib/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
var j = jQuery.noConflict();
</script>
<!-- Add fancyBox main JS and CSS files -->
<script type="text/javascript" src="source/jquery.fancybox.js?v=2.1.3"></script>
<link rel="stylesheet" type="text/css" href="source/jquery.fancybox.css?v=2.1.2" media="screen" />
<script src="http://jwpsrv.com/library/WDP87vS0EeKnIhIxOUCPzg.js"></script>
<script type="text/javascript">
$(document).ready(function() {
/*
* Simple image gallery. Uses default settings
*/
$('.fancybox').fancybox();
/*
* Different effects
*/
// Change title type, overlay closing speed
$(".fancybox-effects-a").fancybox({
helpers: {
title : {
type : 'outside'
},
overlay : {
speedOut : 0
}
}
});
// Disable opening and closing animations, change title type
$(".fancybox-effects-b").fancybox({
openEffect : 'none',
closeEffect : 'none',
helpers : {
title : {
type : 'over'
}
}
});
// Set custom style, close if clicked, change title type and overlay color
$(".fancybox-effects-c").fancybox({
wrapCSS : 'fancybox-custom',
closeClick : true,
openEffect : 'none',
helpers : {
title : {
type : 'inside'
},
overlay : {
css : {
'background' : 'rgba(238,238,238,0.85)'
}
}
}
});
// Remove padding, set opening and closing animations, close if clicked and disable overlay
$(".fancybox-effects-d").fancybox({
padding: 0,
openEffect : 'elastic',
openSpeed : 150,
closeEffect : 'elastic',
closeSpeed : 150,
closeClick : true,
helpers : {
overlay : null
}
});
/*
* Button helper. Disable animations, hide close button, change title type and content
*/
$('.fancybox-buttons').fancybox({
openEffect : 'none',
closeEffect : 'none',
prevEffect : 'none',
nextEffect : 'none',
closeBtn : false,
helpers : {
title : {
type : 'inside'
},
buttons : {}
},
afterLoad : function() {
this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
}
});
/*
* Thumbnail helper. Disable animations, hide close button, arrows and slide to next gallery item if clicked
*/
$('.fancybox-thumbs').fancybox({
prevEffect : 'none',
nextEffect : 'none',
closeBtn : false,
arrows : false,
nextClick : true,
helpers : {
thumbs : {
width : 50,
height : 50
}
}
});
/*
* Media helper. Group items, disable animations, hide arrows, enable media and button helpers.
*/
$('.fancybox-media')
.attr('rel', 'media-gallery')
.fancybox({
openEffect : 'none',
closeEffect : 'none',
prevEffect : 'none',
nextEffect : 'none',
arrows : false,
helpers : {
media : {},
buttons : {}
}
});
/*
* Open manually
*/
$("#fancybox-manual-a").click(function() {
$.fancybox.open('1_b.jpg');
});
$("#fancybox-manual-b").click(function() {
$.fancybox.open({
href : 'conscious-video.html',
type : 'iframe',
padding : 5
});
});
$("#fancybox-manual-c").click(function() {
$.fancybox.open([
{
href : '1_b.jpg',
title : 'My title'
}, {
href : '2_b.jpg',
title : '2nd title'
}, {
href : '3_b.jpg'
}
], {
helpers : {
thumbs : {
width: 75,
height: 50
}
}
});
});
});
</script>
<!------Autoresponder---->
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function() {
var close_note = $("#note");
close_note.click(function () {
j("#note").slideUp(1000, function () {
j(this).hide();
});
});
$("#ajax-contact-form").submit(function() {
$('#load').append('<center><img src="images/ajax-loader.gif" alt="Currently Loading" id="loading" /></center>');
var fem = $(this).serialize(),
note = $('#note');
$.ajax({
type: "POST",
url: "contact.php",
data: fem,
success: function(msg) {
if ( note.height() ) {
note.slideUp(1000, function() {
$(this).hide();
});
}
else note.hide();
$('#loading').fadeOut(300, function() {
$(this).remove();
if(msg === 'OK') {
$('input').val("");
$('textarea').val("");
}
// Message Sent? Show the 'Thank You' message and hide the form
result = (msg === 'OK') ? '<div class="success">Your message has been sent. Thank you!</div>' : msg;
var i = setInterval(function() {
if ( !note.is(':visible') ) {
note.html(result).slideDown(1000);
clearInterval(i);
}
}, 40);
}); // end loading image fadeOut
}
});
return false;
});
});
/* ]]> */
</script>
var j=jQuery.noConflict();
$(文档).ready(函数(){
/*
*简单图像库。使用默认设置
*/
$('.fancybox').fancybox();
/*
*不同效果
*/
//更改标题类型、覆盖关闭速度
$(“.fancybox-effects-a”).fancybox({
助手:{
标题:{
类型:“外部”
},
覆盖:{
加速输出:0
}
}
});
//禁用打开和关闭动画,更改标题类型
$(“.fancybox-effects-b”).fancybox({
openEffect:'无',
closeEffect:'无',
助手:{
标题:{
键入:“结束”
}
}
});
//设置自定义样式,单击后关闭,更改标题类型和覆盖颜色
$(“.fancybox-effects-c”).fancybox({
wrapCSS:“fancybox定制”,
closeClick:true,
openEffect:'无',
助手:{
标题:{
类型:“内部”
},
覆盖:{
css:{
‘背景’:‘rgba(238,0.85)’
}
}
}
});
//删除填充,设置打开和关闭动画,单击后关闭并禁用覆盖
$(“.fancybox-effects-d”).fancybox({
填充:0,
openEffect:'弹性',
开放速度:150,
闭合效应:“弹性”,
接近速度:150,
closeClick:true,
助手:{
覆盖:空
}
});
/*
*按钮助手。禁用动画,隐藏关闭按钮,更改标题类型和内容
*/
$('.fancybox按钮').fancybox({
openEffect:'无',
closeEffect:'无',
效果:“无”,
下一个效果:“无”,
closeBtn:false,
助手:{
标题:{
类型:“内部”
},
按钮:{}
},
后加载:函数(){
this.title='Image'+(this.index+1)+'of'+this.group.length+(this.title?'-'+this.title:'');
}
});
/*
*缩略图帮助程序。禁用动画、隐藏关闭按钮、箭头,并在单击时滑动到下一个库项目
*/
$('.fancybox拇指')。fancybox({
效果:“无”,
下一个效果:“无”,
closeBtn:false,
箭头:错,
下一步:没错,
助手:{
拇指:{
宽度:50,
身高:50
}
}
});
/*
*媒体助手。分组项目、禁用动画、隐藏箭头、启用媒体和按钮助手。
*/
$(“.fancybox媒体”)
.attr('rel','media gallery')
.fancybox({
openEffect:'无',
closeEffect:'无',
效果:“无”,
下一个效果:“无”,
箭头:错,
助手:{
媒体:{},
按钮:{}
}
});
/*
*手动打开
*/
$(“#fancybox-manual-a”)。单击(函数(){
$.fancybox.open('1_b.jpg');
});
$(“#fancybox-manual-b”)。单击(函数(){
$.fancybox.open({
href:“意识视频.html”,
键入:“iframe”,
填充:5
});
});
$(“#fancybox-manual-c”)。单击(函数(){
$.fancybox.open([
{
href:'1_b.jpg',
标题:“我的标题”
}, {
href:'2_b.jpg',
标题:“第二名”
}, {
href:'3_b.jpg'
}
], {
助手:{
拇指:{
宽度:75,
身高:50
}
}
});
});
});
/* */
请勿在同一页面内使用两个版本的jQuery(不推荐)
应该在使用两个不同的库争夺$(jQuery的别名)时使用
许多JavaScript库使用$作为函数或变量名,只是
就像jQuery一样。在jQuery中,$只是jQuery的别名,所以
所有功能均可用,无需使用$。如果您需要使用
jQuery旁边的另一个JavaScript库,返回$back控件
调用$.noConflict()调用另一个库。旧的参考文献
在jQuery初始化过程中保存$;noConflict()只恢复
他们
但是。。。就你而言。。。医生说:
如果出于某种原因加载了两个版本的jQuery(这不是
建议),从第二个版本调用$.noConflict(true)
将全局范围的jQuery变量返回到第一个
版本
更多信息:
祝你好运。包含两个不同(在本例中是非常不同的)版本的jQuery总是会带来灾难。如果联系人表单代码真的依赖于如此古老的库版本,那么它可能无论如何都不应该被使用
jQuery.noConflict()