javascript - Count number of slides and inner to another div -


i try display number on orbit slider foundation 6. i've change previous , next navigation buttons. hot show slider number instead orbit bullets. need total , current slides.

like on example enter image description here

(function () {  function slidenumber() {  var $slides = $('.orbit-slide');  var $activeslide = $slides.filter('.is-active');  var activenum = $slides.index($activeslide) + 1;  $('.slider-number').innerhtml = activenum;  console.log(activenum); }  $('[data-orbit]').on('slidechange.zf.orbit', slidenumber); })();     <div class="orbit" role="region" aria-label="favorite space   pictures" data-orbit>                 <ul class="orbit-container">                     <button class="orbit-previous"><span class="show-  for-sr">previous slide</span><li></li></button>                     <button class="orbit-next"><span class="show-for-sr">next slide</span><li></li></button>                     <li class="is-active orbit-slide">                         <img class="orbit-image" src="../images/demo-img/screen-shot.png" alt="">                     </li>                     <li class="orbit-slide">                         <img class="orbit-image" src="../images/demo-img/screen-shot.png" alt="">                     </li>                     <li class="orbit-slide">                         <img class="orbit-image" src="../images/demo-img/screen-shot.png" alt="">                     </li>                     <li class="orbit-slide">                         <img class="orbit-image" src="../images/demo-img/event-demo.png" alt="">                     </li>                 </ul>                 <nav class="orbit-bullets">                     <button class="is-active" data-slide="0"><span class="show-for-sr">first slide details.</span><span class="show-for-sr">current slide</span></button>                     <button data-slide="1"><span class="show-for-sr">second slide details.</span></button>                     <button data-slide="2"><span class="show-for-sr">third slide details.</span></button>                     <button data-slide="3"><span class="show-for-       sr">fourth slide details.</span></button>                 </nav>                 <div class="slider-number"></div>             </div> 

   it's work great.    (function() {         function slidenumber() {             var totalitems = $('li.orbit-slide').length;             var currentitem = $('li.orbit-slide.is-active').index() - 1;             $('.slider-number').html(currentitem + '/' + totalitems);         }         document.addeventlistener("domcontentloaded", function() {             $('[data-orbit]').on('slidechange.zf.orbit', slidenumber);         });     })(); 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -