首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >easy_jquery_auto_image_rotator的前一个按钮

easy_jquery_auto_image_rotator的前一个按钮
EN

Stack Overflow用户
提问于 2014-11-19 22:49:12
回答 1查看 30关注 0票数 0

我使用这个简单的图像旋转器,但我想添加一个先前的按钮。我已经算出了“下一步”按钮,但我很难回去。下面是代码:视图代码

对于next按钮,我刚刚调用了“旋转式()”,但我不知道如何修改它,使其转到另一种方式。任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-19 23:43:26

基于函数rotate(),我管理了另一个rotate2()。注意功能结束:新的时间间隔。完整解决方案:http://jsfiddle.net/wt6nc0uz/1/

代码语言:javascript
复制
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');

};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27028531

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档