【问题标题】:Get the number of available images and remaining images of a Jssor slider获取一个 Jssor 滑块的可用图像数量和剩余图像数量
【发布时间】:2016-04-25 10:39:57
【问题描述】:

我有一个显示图像的 Jssor 滑块,并希望显示右侧滑块中剩余图像的数量,以及左侧的图像总数。请以随附的屏幕截图为例。

滑块选项:

< script type = "text/javascript" >
  jQuery(document).ready(function($) {

    var jssor_1_options = {
      $AutoPlay: false,
      $AutoPlaySteps: 4,
      $SlideDuration: 160,
      $SlideWidth: 200,
      $SlideSpacing: 3,
      $Cols: 4,
      $Captions: true,
      $ArrowNavigatorOptions: {
        $Class: $JssorArrowNavigator$,
        $Steps: 1
      },
      $BulletNavigatorOptions: {
        $Class: $JssorBulletNavigator$,
        $SpacingX: 1,
        $SpacingY: 1
      }
    };

    var jssor_1_slider = new $JssorSlider$("jssor_1", jssor_1_options);
< /script>

html:

<div class="imgSlider">
  <div id="jssor_1" style="position: relative; margin: 0 auto; top: 0px; left: -30px; width: 1000px ! important; height: 150px; overflow: hidden; visibility: hidden;">


      <div style="display: none;">
        <img data-u="image" src="Content/img/logo1.jpg" />
        <div class="caption" style="position: fixed; top: 90px; left: 80px; width: auto; height: 0px; font-weight: bold; text-align:center; font-size: 15px;" u="caption">
          <p>Report1</p>
        </div>
      </div>
      <div style=": none;">
        <img data-u="image" src="Content/img/logo2.jpg" />
        <div class="caption" style="position: fixed; top: 90px; left: 80px; width: auto; height: 0px; font-weight: bold;text-align:center; font-size: 15px;" u="caption">
          <p>Report2</p>
        </div>
      </div>

      <!--more slides-->

  </div>
</div>

【问题讨论】:

    标签: jquery jssor


    【解决方案1】:

    你得到这样的图像总数:

    tot_img=$('img[data-u="image"]').length;
    

    剩余图片:使用jssor的事件$EVT_PARK获取幻灯片的当前索引。剩余图像只是从总图像中减去:

    tot_img=$('img[data-u="image"]').length;
    jssor_1_slider.$On($JssorSlider$.$EVT_PARK,function(slideIndex, fromIndex){
        console.log('remaining:'+ parseInt(tot_img-slideIndex-1))
    });
    

    更多关于 jssor api 的信息here

    小提琴:here

    【讨论】:

    • 我尝试使用上面的代码,但没有得到结果。你能告诉我我应该在哪里使用你在我的代码中提供的代码行吗?谢谢
    • 我已经用我的滑块测试了这个。将代码放在声明滑块的行下方: var jssor_1_slider=new $JssorSlider$("jssor_1", jssor_1_options);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    • 1970-01-01
    • 2013-06-25
    • 1970-01-01
    相关资源
    最近更新 更多