jquery - slick.js on last slide show alert -


i'm using slick.js http://kenwheeler.github.io/slick/ run through slides, last of should toggle alert.

after ferreting around online , realizing should work without having hard code number of slides (and having seen solution: slick carousel. want autoplay play slides once , stop ), i've got following code:

$(document).ready(function(){           var item_length = $('.slider > div').length - 1;           $('.slider').slick({             appendarrows : '.arrow-holder',             adaptiveheight : true,             infinite : false,             onafterchange: function(){                 if( item_length == slider.slickcurrentslide() ){                     alert("slide 2");                 };             }           });          }); 

unfortunately, nothing happens when reach last slide. nor seem if hard code in last number, taking account 0 indexing.

i have no errors or warnings in console, struggling work out how figure out problem.

your onafterchange function lacking input needs slick. code should fix it:

 $(document).ready(function(){       var item_length = $('.slider > div').length - 1;       $('.slider').slick({         appendarrows : '.arrow-holder',         adaptiveheight : true,         infinite : false,         onafterchange: function(slide, index){             if( item_length == index ){                 alert("slide 2");             };         }       });      }); 

note index[0] first slide


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -