weixin_33705053 2012-10-16 08:56 采纳率: 0%
浏览 16

滑块中的图像计数(1/10)

It's a slide of images that have auto fadeIn and also I can control it by the arrows in the bottom left (next and prev arrows). The problem it's that I want to show a total of images and the current number of the one we are watching (like the numbering between the arrows), I have made the markup but I have search a lot on how to programming the number but couldn't find anything similar. Can someone help me out please?

This is the markup:

<div id="slideshow">
    <ul id="slides">
        <li><img src="img/project_image.jpg" /></li>
        <li><img src="img/project_image2.jpg"/></li>
        <li><img src="img/project_image3.jpg" /></li>
        <li><img src="img/project_image4.jpg" /></li>
    </ul>
</div>

<div class="project_navigation" class="clearfix">
    <ul id="nav">
        <li id="prev"><a href="#">Previous</a></li>
        <div class="project_number">
            <p>10/12</p>
        </div>
        <li id="next"><a href="#">Next</a></li>
    </ul>
</div>

This is how I call the slider:

  $("#slideshow").css("overflow", "hidden");

  $("ul#slides").cycle({
      fx: 'fade',
      pause: 1,
      prev: '#prev',
      next: '#next'
  });

And i'm using this plugin: http://jquery.malsup.com/cycle/

  • 写回答

2条回答 默认 最新

  • weixin_33721427 2012-10-16 09:08
    关注

    See for onPrevNextEvent callback function of this plugin.

    $("ul#slides").cycle({
          fx: 'fade',
          pause: 1,
          prev: '#prev',
          next: '#next',
          onPrevNextEvent : function(isNext, zeroBasedSlideIndex, slideElement){
               $('.project_number p').text(zeroBasedSlideIndex+'/'+$("ul#slides img").length);
          }
      });
    

    Doesnt test this code, but maybe onPrevNextEvent is fired before the cycle is done. In this case, you should look at isNext parameter or onAfter event.

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制