两段js 代码冲突 总有一个不能用
代码1:$(function(){(function(){varcurr=0;$("#jsNav.trigger").each(function(i){$(this).c...
代码1:
$(function(){
(function(){
var curr = 0;
$("#jsNav .trigger").each(function(i){
$(this).click(function(){
curr = i;
$("#js img").eq(i).fadeIn("slow").siblings("img").hide();
$(this).siblings(".trigger").removeClass("imgSelected").end().addClass("imgSelected");
return false;
});
});
var pg = function(flag){
//flag:true表示前翻, false表示后翻
if (flag) {
if (curr == 0) {
todo = 2;
} else {
todo = (curr - 1) % 3;
}
} else {
todo = (curr + 1) % 3;
}
$("#jsNav .trigger").eq(todo).click();
};
//前翻
$("#prev").click(function(){
pg(true);
return false;
});
//后翻
$("#next").click(function(){
pg(false);
return false;
});
//自动翻
var timer = setInterval(function(){
todo = (curr + 1) % 3;
$("#jsNav .trigger").eq(todo).click();
},4000);
//鼠标悬停在触发器上时停止自动翻
$("#jsNav a").hover(function(){
clearInterval(timer);
},
function(){
timer = setInterval(function(){
todo = (curr + 1) % 3;
$("#jsNav .trigger").eq(todo).click();
},1500);
}
);
})();
});
//]]>
代码2:
var Scrolling=false;
function $(o){return document.getElementById(o)}
function ScroMove(){Scrolling=true}
document.onmousemove=function(e){if(Scrolling==false)return;ScroNow(e)}
document.onmouseup=function(e){Scrolling=false}
function ScroNow(event){
var event=event?event:(window.event?window.event:null);
var Y=event.clientX-$("Scroll").getBoundingClientRect().left-$("ScroLine").clientHeight/2-150;
var H=$("ScroRight").clientWidth-$("ScroLine").clientHeight-50;
var SH=Y/H*($("ScroLeft").scrollHeight-$("ScroLeft").clientHeight);
if (Y<0)Y=0;if (Y>H)Y=H;
$("ScroLine").style.left=Y+"px";
$("ScroLeft").scrollTop=SH;
}
function ScrollWheel(){
var Y=$("ScroLeft").scrollTop;
var H=$("ScroLeft").scrollHeight-$("ScroLeft").clientHeight;
if (event.wheelDelta >=120){Y=Y-80}else{Y=Y+80}
if(Y<0)Y=0;if(Y>H)Y=H;
$("ScroLeft").scrollTop=Y;
var SH=Y/H*$("ScroRight").clientWidth-$("ScroLine").clientWidth;
if(SH<0)SH=0;
$("ScroLine").style.left=SH+"px";
} 展开
$(function(){
(function(){
var curr = 0;
$("#jsNav .trigger").each(function(i){
$(this).click(function(){
curr = i;
$("#js img").eq(i).fadeIn("slow").siblings("img").hide();
$(this).siblings(".trigger").removeClass("imgSelected").end().addClass("imgSelected");
return false;
});
});
var pg = function(flag){
//flag:true表示前翻, false表示后翻
if (flag) {
if (curr == 0) {
todo = 2;
} else {
todo = (curr - 1) % 3;
}
} else {
todo = (curr + 1) % 3;
}
$("#jsNav .trigger").eq(todo).click();
};
//前翻
$("#prev").click(function(){
pg(true);
return false;
});
//后翻
$("#next").click(function(){
pg(false);
return false;
});
//自动翻
var timer = setInterval(function(){
todo = (curr + 1) % 3;
$("#jsNav .trigger").eq(todo).click();
},4000);
//鼠标悬停在触发器上时停止自动翻
$("#jsNav a").hover(function(){
clearInterval(timer);
},
function(){
timer = setInterval(function(){
todo = (curr + 1) % 3;
$("#jsNav .trigger").eq(todo).click();
},1500);
}
);
})();
});
//]]>
代码2:
var Scrolling=false;
function $(o){return document.getElementById(o)}
function ScroMove(){Scrolling=true}
document.onmousemove=function(e){if(Scrolling==false)return;ScroNow(e)}
document.onmouseup=function(e){Scrolling=false}
function ScroNow(event){
var event=event?event:(window.event?window.event:null);
var Y=event.clientX-$("Scroll").getBoundingClientRect().left-$("ScroLine").clientHeight/2-150;
var H=$("ScroRight").clientWidth-$("ScroLine").clientHeight-50;
var SH=Y/H*($("ScroLeft").scrollHeight-$("ScroLeft").clientHeight);
if (Y<0)Y=0;if (Y>H)Y=H;
$("ScroLine").style.left=Y+"px";
$("ScroLeft").scrollTop=SH;
}
function ScrollWheel(){
var Y=$("ScroLeft").scrollTop;
var H=$("ScroLeft").scrollHeight-$("ScroLeft").clientHeight;
if (event.wheelDelta >=120){Y=Y-80}else{Y=Y+80}
if(Y<0)Y=0;if(Y>H)Y=H;
$("ScroLeft").scrollTop=Y;
var SH=Y/H*$("ScroRight").clientWidth-$("ScroLine").clientWidth;
if(SH<0)SH=0;
$("ScroLine").style.left=SH+"px";
} 展开
2012-05-19
展开全部
代码2:
var Scrolling=false;
function ScroMove(){Scrolling=true}
document.onmousemove=function(e){if(Scrolling==false)return;ScroNow(e)}
document.onmouseup=function(e){Scrolling=false}
function ScroNow(event){
var event=event?event:(window.event?window.event:null);
var Y=event.clientX-document.getElementById("Scroll").getBoundingClientRect().left-document.getElementById("ScroLine").clientHeight/2-150;
var H=document.getElementById("ScroRight").clientWidth-document.getElementById("ScroLine").clientHeight-50;
var SH=Y/H*(document.getElementById("ScroLeft").scrollHeight-document.getElementById("ScroLeft").clientHeight);
if (Y<0)Y=0;if (Y>H)Y=H;
document.getElementById("ScroLine").style.left=Y+"px";
document.getElementById("ScroLeft").scrollTop=SH;
}
function ScrollWheel(){
var Y=document.getElementById("ScroLeft").scrollTop;
var H=document.getElementById("ScroLeft").scrollHeight-document.getElementById("ScroLeft").clientHeight;
if (event.wheelDelta >=120){Y=Y-80}else{Y=Y+80}
if(Y<0)Y=0;if(Y>H)Y=H;
document.getElementById("ScroLeft").scrollTop=Y;
var SH=Y/H*document.getElementById("ScroRight").clientWidth-document.getElementById("ScroLine").clientWidth;
if(SH<0)SH=0;
document.getElementById("ScroLine").style.left=SH+"px";
}
var Scrolling=false;
function ScroMove(){Scrolling=true}
document.onmousemove=function(e){if(Scrolling==false)return;ScroNow(e)}
document.onmouseup=function(e){Scrolling=false}
function ScroNow(event){
var event=event?event:(window.event?window.event:null);
var Y=event.clientX-document.getElementById("Scroll").getBoundingClientRect().left-document.getElementById("ScroLine").clientHeight/2-150;
var H=document.getElementById("ScroRight").clientWidth-document.getElementById("ScroLine").clientHeight-50;
var SH=Y/H*(document.getElementById("ScroLeft").scrollHeight-document.getElementById("ScroLeft").clientHeight);
if (Y<0)Y=0;if (Y>H)Y=H;
document.getElementById("ScroLine").style.left=Y+"px";
document.getElementById("ScroLeft").scrollTop=SH;
}
function ScrollWheel(){
var Y=document.getElementById("ScroLeft").scrollTop;
var H=document.getElementById("ScroLeft").scrollHeight-document.getElementById("ScroLeft").clientHeight;
if (event.wheelDelta >=120){Y=Y-80}else{Y=Y+80}
if(Y<0)Y=0;if(Y>H)Y=H;
document.getElementById("ScroLeft").scrollTop=Y;
var SH=Y/H*document.getElementById("ScroRight").clientWidth-document.getElementById("ScroLine").clientWidth;
if(SH<0)SH=0;
document.getElementById("ScroLine").style.left=SH+"px";
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询