3

我使用的当前方法只是增加afterChange事件的索引值,但是当用户向后导航时这会中断。如何确定当前图像索引是什么?

(function($){ $(function(){

  var i = 0
  var swapColor = function(){
    var index = i++ % $("#slider img").length // gets the calculated index according to hom many times the slider has swapped slides
    var color = $("#slider img").eq(index).data('color')
    $(".nivo-caption, .nivo-html-caption").css({backgroundColor: color})  
  }

  $('#slider').nivoSlider({
    afterLoad: swapColor,
    beforeChange: swapColor
  });

}) })(jQuery);
4

1 回答 1

9

我是用这个方法做的...

var index = $(".nivo-controlNav .active").attr('rel')
于 2012-05-22T12:50:57.230 回答