我使用这个简单的图像旋转器,但我想添加一个先前的按钮。我已经算出了“下一步”按钮,但我很难回去。下面是代码:视图代码
对于next按钮,我刚刚调用了“旋转式()”,但我不知道如何修改它,使其转到另一种方式。任何帮助都将不胜感激。
发布于 2014-11-19 23:43:26
基于函数rotate(),我管理了另一个rotate2()。注意功能结束:新的时间间隔。完整解决方案:http://jsfiddle.net/wt6nc0uz/1/
function rotate2() {
//Get the first image
var current = ($('div.rotator ul li.show')? $('div.rotator ul li.show') : $('div.rotator ul li:first'));
if ( current.length == 0 ) current = $('div.rotator ul li:first');
//Get next image, when it reaches the end, rotate it back to the first image
var prev = ((current.prev().length) ? ((current.prev().hasClass('show')) ? $('div.rotator ul li:last') :current.prev()) : $('div.rotator ul li:last'));
//Set the fade in effect for the next image, the show class has higher z-index
prev.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
//Hide the current image
clearInterval(interval);
current.animate({opacity: 0.0}, 1000, function(){interval=setInterval('rotate2()', 6000);}) .removeClass('show');
};https://stackoverflow.com/questions/27028531
复制相似问题