var timer = null;
var offset = 5000;
var index = 0;//大图交替轮换
function slideImage(i){
var id = 'image_'+ target[i];
$('#'+ id)
.animate({opacity: 1}, 800, function(){
$(this).find('.word').animate({height: 'show'}, 'slow');
}).show()
.siblings(':visible')
.find('.word').animate({height: 'hide'},'fast',function(){
$(this).parent().animate({opacity: 0}, 800).hide();
});
}
//bind thumb a
function hookThumb(){
$('#thumbs li a')
.bind('click', function(){
if (timer) {
clearTimeout(timer);
}
var id = this.id;
index = getIndex(id.substr(6));
rechange(index);
slideImage(index);
timer = window.setTimeout(auto, offset);
this.blur();
return false;
});
}
//bind next/prev img
function hookBtn(){
$('#thumbs li img').filter('#play_prev,#play_next')
.bind('click', function(){
if (timer){
clearTimeout(timer);
}
var id = this.id;
if (id == 'play_prev') {
index--;
if (index < 0) index = 6;
}else{
index++;
if (index > 6) index = 0;
}
rechange(index);
slideImage(index);
timer = window.setTimeout(auto, offset);
});
}
//get index
function getIndex(v){
for(var i=0; i < target.length; i++){
if (target[i] == v) return i;
}
}
function rechange(loop){
var id = 'thumb_'+ target[loop];
$('#thumbs li a.current').removeClass('current');
$('#'+ id).addClass('current');
}
function auto(){
index++;
if (index > 6){
index = 0;
}
rechange(index);
slideImage(index);
timer = window.setTimeout(auto, offset);
}
$(function(){
//change opacity
$('div.word').css({opacity: 0.85});
auto();
hookThumb();
hookBtn();
});
/*-----------------------------------------------------------------------------*/
function marquee(height,speed,delay){
var scrollT;
var pause = false;
var ScrollBox = document.getElementById("topadlink");
if(document.getElementById("holder").offsetHeight <= height) return;
var _tmp = ScrollBox.innerHTML.replace('holder', 'holder2')
ScrollBox.innerHTML += _tmp;
ScrollBox.onmouseover = function(){pause = true}
ScrollBox.onmouseout = function(){pause = false}
ScrollBox.scrollTop = 0;
function start(){
scrollT = setInterval(scrolling,speed);
if(!pause) ScrollBox.scrollTop += 2;
}
function scrolling(){
if(ScrollBox.scrollTop % height != 0){
ScrollBox.scrollTop += 2;
if(ScrollBox.scrollTop >= ScrollBox.scrollHeight/2) ScrollBox.scrollTop = 0;
}
else{
clearInterval(scrollT);
setTimeout(start,delay);
}
}
setTimeout(start,delay);
}
marquee(24,30,3000);
请问这2段JS一个是文字上翻公告的JS。一个是大图轮换的JS。每个页面单独用都没问题,但这2个效果放一个页面会起冲突(2个效果都不动了) 原因在哪呢?。我看不大懂。有朋友指点说修改起冲突的参数,可改哪里呢。请指教?不胜感激
解决方案 »
- ie 下对于 js 去掉字串的空格,无效
- 去哪儿网的一道面试题
- Jquery编写的插件如何返回值
- 这个Javascript编程是怎么一回事?css:function(el, targetclass, action){?前台就包含一下这个文件就可以用了。
- dom 滚动事件里,怎么判断是水平滚动还是垂直滚动
- 为什么我调用不了function里面的add()函数,如果去掉form就可以?
- 如果<td>的宽度是百分比,哪么<input type=text>的宽度等于当前<td>的度度怎么做啊?
- 如何控制是否下载完成
- 如何用JAVASCRIPT来清除IE临时文件(缓存)
- java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
- onclick=window.open()被ff和gg浏览器拦截怎么解决打开新网页?
- 关于jQuery组件问题
看看