隐藏/显示工作正常,但幻灯片不起作用



我正在开发一个新闻自动收报机,它基本上隐藏了一个标题并显示下一个标题。一切都在工作,但一旦我使用 hide('slide'( 方法,它就会停止工作。它通过滑动来隐藏第一个元素,但从不显示下一个元素。

注意 - 我已经添加了所有必需的JS文件,所以这不是问题。

//Slide Headlines **(Working Code Without Sliding)**
setInterval(function(){
$('.headlines_container a').each(function(){
if($(this).css('display') != 'none'){
$(this).hide();
if($(this).next().is('a')){
$(this).next('a').show();
return false;
}else{  
$(this).closest('.headlines_container').find('a').first().show();
return false;
}
}
});
},2000);

//Slide Headlines **(Not Working)**
setInterval(function(){
$('.headlines_container a').each(function(){
if($(this).css('display') != 'none'){
$(this).hide('slide',{direction:'left'});
if($(this).next().is('a')){
$(this).next('a').show('slide',{direction:'right'});
return false;
}else{  
$(this).closest('.headlines_container').find('a').first().show('slide',{direction:'right'});
return false;
}
}
});
},2000);

$(this).hide('slide',{direction:'left'});需要jQuery-ui library。您是否正在使用该库?调用函数时,您也可以传递时间跨度hide

$(this).hide('slide',{direction:'left'}, 1000);

看看这里

http://jsfiddle.net/ZQTFq/

最新更新